LAMP stands for Linux Apache MySQL PHP server. It’s native to a Ubuntu Server edition install but has to be installed separately in a Ubuntu Desktop edition. In this tutorial, we will go through the steps to install the LAMP server on any Ubuntu Desktop edition PCs. We will also add the step of installation of phpMyAdmin, a nice tool for PHP newbies for dealing with the MySQL database. The following tutorial is relevant for installation on Ubuntu Hardy (8.04), Intrepid (8.14), Jaunty (9.04), Karmic (9.14) and Lucid (10.04)
LAMP Server installation
The canonical maintains the latest LAMP and phpMyAdmin builds on its servers. So the first step is to install the LAMP server via aptitude. Type this at command line:
sudo apt-get install lamp-server^
Note the “^” has to be there.
During the process of installation, you will be prompted to setup the root password for MySQL. Enter the password and hit OK (you can browse through the page navigation options by hitting Tab key).
Now the last step is to check that MySQL database is correctly binded to the http://localhost. Type this in a Terminal:
cat /etc/hosts | grep localhost
You should see something like “127.0.0.1 localhost” . This means that localhost is at IP http://127.0.0.1
Now lets check that MySQL is correctly bound to this IP. Type this on Terminal:
cat /etc/mysql/my.cnf | grep bind-address
You should see something like this bind-address = 127.0.0.1
If you don’t see 127.0.0.1 (or the IP for localhost that you saw when you did
cat /etc/hosts | grep localhost ), then you will need to correct it (you can correct it by:
gksudo gedit /etc/mysql/my.cnf )
This completes the LAMP server installation.
Now also install the phpMyAdmin. Type this at command line:
sudo apt-get install libapache2-mod-auth-mysql phpmyadmin
During the installation, you will be first prompted to select a web server for automatic configuration. This step is in caps as most people goof it up, and later have problems with accessing phpMyAdmin via Apache: USE YOUR KEYBOARD’S SPACE-BAR FOR SELECTING APACHE2 AND THEN HIT ENTER.
After this, you will be asked to configure a new database called dbconfig-common. This being a new installation, use the Tab key to select Yes and then hit Enter.
Now, you will be asked to setup MySQL root password. Use the same root password for MySQL that you created while doing LAMP installation. Then use Tab to highlight Ok and hit Enter.
After this, you will be prompted to setup a MySQL application password for phpMyAdmin. Use the same root password for MySQL that you created while doing LAMP installation. Hit Enter. Then confirm the password and again hit Enter. This will complete the phpMyAdmin installation.
Test Apache webserver installation
Now you need to make sure that your webserver (Apache) is working correctly. Type this on a terminal:
You should see firefox web-browser display “It works!” in bold. This means that the Apache web-server is up and running.
Test PHP and phpMyAdmin installations
OK, in Ubuntu, the webserver looks at /var/www directory by default for any web-page accessed like this http://localhost/my_first_web_page.php . Of course “my_first_web_page.php” is just a file-name used as a demonstration to test php installation. You can use whatever file name you like, however retain the .php file extension.
So, now type this in a terminal:
gksudo gedit /var/www/my_first_web_page.php
Copy-Paste the following lines into the text-editor gedit:
Save and close gedit. The reboot Apache webserver by typing this on Terminal:
sudo /etc/init.d/apache2 restart
After this, again type this on Terminal:
You should see firefox displaying info about php-engine. This means that the install went perfect for php.
Now again in the terminal, type this:
You should see a web-page prompting you to enter user-name and password. Enter root as username and the password as the one you gave when doing MySQL setup during LAMP server installation. You will be greeted my the phpMyAdmin home screen. This means the phpMyAdmin installation went perfect.
Uninstallation of LAMP server and phpMyAdmin
Okay, so you bungled something when doing either installation or during active development and want to start afresh. So here’s how to remove everything.
Removing LAMP server: Type on a Terminal:
sudo apt-get purge lamp-server^
Removing phpMyAdmin: Type on Terminal:
sudo apt-get purge libapache2-mod-auth-mysql phpmyadmin