Installing LAMP on Ubuntu Jaunty (9.04)
For the latest version, check out Install LAMP on Ubuntu 9.10 Karmic Koala.
Why Install LAMP?
Today I'm going to show how to install and set up a LAMP (Linux, Apache, MySQL, PHP) stack on Ubuntu. Why do this? It's useful if you want to set up an off-line web development environment. If you are building websites and experimenting, it's nice to do it in the privacy of your own computer, rather than "in the wild" out on the internet.
Install LAMP
Ubuntu has an easy way to select and install all of the required packages. It's done with the following command.
Don't forget to include the carrot. According to the Ubuntu documentation, it's magical.
Hit <Enter> to confirm you want to install the packages.
Next, you will be prompted to change the password for the root user on your MySQL database.
Enter your chosen password. Enter it again in the confirmation screen.
After some more chugging in the terminal the installation will complete.
Now we need to test the installation and get things configured.
Testing Apache
Open a web browser and enter the address http://localhost/. You should see a webpage displaying the text "It Works!"
Testing PHP
Now we're going to test our PHP installation. To do this we'll create a file called testing.php in /var/www. Open a terminal and enter:
Enter the line below, save the file, and exit the text editor.
Now we need to restart Apache.
Now, open your browser and enter http://localhost/testing.php/. You should see a bunch of information about your version of PHP.
Configuring MySQL
Now we need to configure MySQL to be associated with the IP address of your machine. Since I'm installing the LAMP stack for a web development environment I'm going to bind MySQL to the localhost IP address, which in my case is 127.0.0.1. You can verify this address with:
Edit the my.cnf file to configure the bind address.
Verify that the bind-address line looks like this (adjust for your IP address).
bind-address = 127.0.0.1Install phpMyAdmin
This step is optional, but phpMyAdmin will make it much easier to administer the MySQL databases.
During the installation you will be prompted to select your web server for automatic configuration. Use the space bar to mark apache2 and then hit <Enter>.
You will also be asked if you want to configure phpMyAdmin with a new database called dbconfig-common. Select Yes and hit <Enter>.
Next you'll be prompted for the password for MySQL's administrator. Enter the MySQL root password that you created earlier in the installation. Hit <Tab> to select Ok and hit <Enter>.
Next you'll be prompted to create an application password for phpMyAdmin to talk to MySQL. If you leave it blank, a random password will be generated for you.
After configuring the password, the installation should complete.
Testing phpMyAdmin
Enter http://localhost/phpmyadmin/ into your web browser. You should see a page that looks like this:
You should be able to log in using the username root and the root password that you created earlier.
Your LAMP installation is now complete.
At this point you may want to do some additional Apache configuration.













thanks a lot. this is the easiest ,shortest, and quickest way to install LAMp....
no hassles. thanks again.
just a small thing... i think, for phpmyadmin to start on the browser, u have to add this line in /etc/apache2/apache2.conf
#for phpmyadmin
Include /etc/phpmyadmin/apache.conf
Sayantan - Thanks for the comment. I didn't have to make any changes to /etc/apache2/apache2.conf. In fact, I just went and checked that file and there is no phpmyadmin line in there. Perhaps your setup is different from mine. I imagine other Linux distros handle things a bit differently.
I went through all of this just yesterday on a fresh install of Jaunty, using the latest packages. I haven't tried this yet on my Hardy install. You're edit may come in handy there.
[...] LAMP ( Thnks to Linerd) [ For those who are afraid of the terminal, Each of these softwares can be installed from [...]
Thanks so much for sharing this easy LAMP install, I just followed your step by step instructions to install LAMP, but when I installed and tried to login phpMyAdmin, I got an error message: Access denies, I did not enter password for MySQL (blank) but I did enter the password for phpMyAdmin, and to login phpMyAdmin, I used root as you said, and the password I created, what have I done wrong?
Thanks,
Michael
Try using the MYSQL password you created in the early part of the process, rather than the PHPMyAdmin password you just created..that worked for me..
Good information. However, al my browsers don't accept a php-file for output. The all ask the question what I want tot do with such a file.
Frans - Did you remember to restart Apache?
sudo /etc/init.d/apache2 restart
thank brother is a good tuto.
Thanks!
hi, nice tutorial... i've installed it successfully.... thanks a lot
[...] ! (mais on peut aussi installer phpMyAdmin pour compléter le tout) This entry was posted in Aventures ordi-naires and tagged Ubuntu. [...]
I have to add this line too.
#for phpmyadmin
Include /etc/phpmyadmin/apache.conf
Emm... at Install phpMyAdmin.. I type
sudo apt-get install libapache2-mod-auth-mysql phpmyadmin
but I suddenly choose apache...how to fix it..i want to choose apache2...help me..I'm newbis
@Darksoul - Do you mean you selected the wrong thing during installation of phpmyadmin? Yo can re-run the configuration with:
Thanks a bunch I went through several tutorials and none worked untill this one. The only thing missing is you didn't tell them to restart apache before checking php..
Thank
John
shot dude! nice post, seamless and easy install thanks to you!
Simple but great tutrorial
THanks a lot !!!
Nice tutorial, worked like a charm.
Thank you!
excellent tutorial.
exactly what i wanted to do and it doesn't get any easier
Wonderful Tutorial
Great contribution. Thanks a mollion
By far the best thought through set of instructions I have found to date. Thank you!
Tom - Glad you liked it.
NICE! This is hands down the easiest to follow LAMP install that I have found, great job.
BTW - I, too, had to add the lines:
#for phpmyadmin
Include /etc/phpmyadmin/apache.conf
at the end of my apache2.conf file. and the RESTART apache and I was good to go!
Thanks again..
Mike
Perfect , clean installation , no one single problem . Thanks a million