How To Install LAMP (Linux, Apache, MySQL, PHP) On Ubuntu 11.04/11.10/12.04 Do you like this story? Ifyou develop web applications and scripts, it will be nice testing them locally in your own computer before launching them online. This will require the installation of a webserver on your computer.
LAMP (Linux,Apache, MySQL, PHP) is one of the easiest and perfect environment where you can test all your PHP codes. In this tutorial, we will help you install the LAMP webserver on Ubuntu 12.04/11.10; can also be installed on older distributions of Ubuntu (11.04/10.10/10.04).
LAMPInstallation
The LAMP webserver can be installed easily with this command (the caret (^)is required, don't exclude it):
sudoapt-get install lamp-server^
During the installation, you will be asked to enter a new root password for the MySQL database, submit it and press Enter:You will be prompted to enter the password again for confirmation. Wait now until the installation is complete. You have now installed the LAMP webserver on Ubuntu 11.04/11.10. Let's now go to the next step.
TestingApache
Launch your web browser (Firefox, Google Chrome, etc.) and open one of these addresses:
http://localhost/
or
http://127.0.0.1/
If you get this page, then Apache isstarted:Otherwise try to restart Apache with this command:
sudo/etc/init.d/apache2 restart
Then give it another try.
TestingPHP
Let's now test PHP. You need to create an empty PHP file in /var/www andinsert this snippet of code into it:
<?phpphpinfo(); ?>
You can easily do it with these two commands via the terminal:
echo"<?php phpinfo(); ?>" | sudo tee /var/www/test.php
sudo /etc/init.d/apache2 restart
Then open this address:
http://localhost/test.php
You should see a page like this:ConfiguringMySQL
Since you are using the LAMP webserver locally, your MySQL database must uses the same IP address of your localhost which is: 127.0.0.1.Via the Terminal, run this command to verify it:
During the installation you will be asked to select a web server that will be configured automatically to run phpMyAdmin. Select apache2 usingyour spacebar and press Enter:You will be asked next to configure a database for phpmyadmin with dbconfig-common,select Yes andpress Enter:In the next screen, enter the MySQL password you have submitted before and press Enter:Congratulation! phpMyAdmin is now installed in your system. To test it, open simply this address via your web browser:
http://localhost/phpmyadmin/
Login to phpMyAdmin using root asusername and the password you created earlier:You have now successfully installed LAMP on your system. All your projects and files must be placed in /var/www sothat you can run them.
RemovingLAMP & phpMyAdmin
To uninstall the LAMP web server and phpMyAdmin, open the terminal and run this command: