|Installing LAMP(Apache Web Server/PHP/MySQL) in Debian |
05/14/2009 | Wow! | 820 views | 0 Comments »
Installing the LAMP environment on a Linux system is easy if you are comfortable with using the native package management software. If you on a Red Hat/Fedora/CentOS system, that will be yum – and for Debian/Ubuntu systems, that will be apt. This tutorial shows you how to install Apache 2, PHP 5 and MySQL 5 in Debian using apt.
Before installation, a few points to remember. These instruction are not for a production environment – this is for a development environment. To install the software, you need root access. You can get that using this command…
[Enter root password]
Installing Apache 2
Use this command to install Apache 2.
apt-get install apache2
Make sure you specify ‘apache2? – or else, apache 1.3 will be installed.
Install PHP 5
Now, install the PHP 5 packages…
apt-get install libapache2-mod-php5 php5-cli php5-common php5-cgi
No go to the folder
and edit the file in that directory(usually 000-default). Find the line that says
RedirectMatch ^/$ /apache2-default/
and remove it.
Now your document root is
– place all your HTML documents and scripts in this folder. If you want to make some other configuration changes, edit the configuration files at
I also had to make the following changes…
Changed the owner of
to www-data – I used the command
chown www-data:www-data apache2
Created an empty file at
This was to fix a few errors I saw on my system – you may not have to do it.
This is the command to install MySQL server, its client and PHP’s MySQL libraries…
apt-get install mysql-client mysql-common mysql-server php5-mysql
Finally, Install the other packages you need as well
apt-get install php5-sqlite php5-gd ...
Testing the System
Go to your document root(
) and create a php files called ‘info.php’ and put this code inside that…
Start the Servers
First, turn on the MySQL database server…
Then, start the Apache Web Server…
Now fire up a browser and go to localhost – you should see a file listing page with a ‘info.php’ in the list. Click on that link – if you see a PHP information page, your web server is setup correctly.
To make sure MySQL-PHP connection is working, install phpMyAdmin – or write a database connection script – whatever is easier for you.
This entry was posted on Thursday, May 14th, 2009 at 1:35 am and is filed under Domain/Hosting, Linux. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.