As a web developer I prefer to work on my development environment before rolling out the changes to Production environment. For the same I use Apache, MySQL and PHP package on my Ubuntu 12.04 box. Today’s article is about how to install all these packages with minimum commands and efforts. To achieve this we are going to install LAMP on our Ubuntu box. LAMP (Linux, Apache, MySQL and PHP) is an open source Web development platform that uses Linux as operating system, Apache as the Web server, MySQL as the relational database management system and PHP as the object-oriented scripting language.
Step 1 Open a command prompt and run following command to install LAMP
sudo apt-get install lamp-server^
Your LAMP installation is now complete. Just a single command to install all three package on a ubuntu box.
LAMP will install the default things. Now we have to modify certain parameters as per our need.
Run following command to restart your apache2 server
Since this tutorial is for setting up a local web development environment, the MySQL needs to be bound to the localhost IP address. By default this should be 127.0.0.1 on your system. Just in case, you can verify it with these commands.
cat /etc/hosts | grep localhost
You should see something like
You now want to verify that you have the correct bind address in MySQL's my.cnf file. <pre lang="bash"> cat /etc/mysql/my.cnf | grep bind-address
You should see:
bind-address = 127.0.0.1
If the bind address doesn’t match the one set for localhost on your system, you’ll need to edit/etc/mysql/my.cnf as root to correct it.
Now that you’ve confirmed that the Apache web server works, you want to make sure that your php installation is working. To do that you need to create a file in /var/www called testing.php. You can use your favorite text editor as root, or you can use the following terminal command:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/testing.php