Install LAMP on Ubuntu 9.10 Karmic Koala
Why install LAMP on your desktop computer?
Why would I want to install and set up a LAMP (Linux, Apache, MySQL, php) stack on Ubuntu 9.10? It’s useful if you want to set up a private web development environment. Perhaps you want to develop your own WordPress theme. If you are developing websites and experimenting, it’s nice to do it in the privacy of your own computer, rather than out on the public internet.
Install LAMP
The Ubuntu developers have created a very easy way to install a LAMP server on an existing system. It's all kicked off with this one simple terminal command.
Note: Please make note of the caret (^) in the above command, it's not a typo, it's required to make the command work.
The apt package manager will show all the packages that need to be installed. Hit <Enter> to confirm that you want to install them.
You will then be prompted to change the password for the root user on the MySQL database.
Enter the password you want. You'll be prompted to enter it a second time to confirm.
After you confirm your password, apt will continue to install the rest of the packages.
Congratulations, your LAMP installation is complete! That was the easy part, now you need to get things configured to make the system easy to work with.
Test Apache
Open a web browser and enter the address http://localhost/. You should see a web page that says "It Works!"
Testing php
Now that you know Apache works, it's time to test the php installation. You'll need to create a file in /var/www called testing.php. Open a terminal and enter:
Enter the following line into the text editor, save the file and exit.
Next, restart Apache with the following terminal command.
Now go back to your web browser and enter the address http://localhost/testing.php/. You should see a page displaying version information for your php installation.
Configuring MySQL
Since I'm installing LAMP for a web development environment, I want to bind the MySQL database to the localhost IP address. This should be 127.0.0.1 for your system. You can verify it with this terminal command.
You'll now want to verify that the correct bind address is set up in the my.cnf file.
You should see a line that looks like
bind-address = 127.0.0.1
If the IP address doesn't match the one for your system, you'll need to edit the my.cnf file to correct it.
Install phpMyAdmin
You don't need to install phpMyAdmin, but it's a much easier way to get in and muck around with things in your MySQL database if you're not familiar with the MySQL commands. You can install phpMyAdmin from the command line with
The installation will prompt you to select a web server for automatic configuration. Use the space bar on your keyboard to select apache2 and then hit <Enter>.
Another screen will come up asking if you want to configure a new database called dbconfig-common. Since this is a fresh installation, use the <Tab> key to select Yes and hit <Enter>.
You'll be prompted next to enter the MySQL root password. Enter the MySQL root password that you created earlier, hit <Tab> to select Ok and hit <Enter>.
You'll then be prompted to enter a MySQL application password for phpmyadmin. You can hit <Enter> and a random password will be generated. I chose to use the same password that I used for the root MySQL password. If you enter your own password, a password confirmation screen will come up. Confirm your password.
The phpMyAdmin installation is now complete.
Testing phpMyAdmin
Open your web browser and enter the address http://localhost/phpmyadmin/. You should see a page like this.
You can log in with the username root and the root password that you created earlier.
Congratulations, you're now ready to start building your local website. If you're only working on one site you can put all of the files into /var/www. If you'll be working on multiple sites you may want to consider some additional Apache configuration to keep things neat and clean on you system.














Another Question:
How do I copy paste wordpress files or Joomla files to folder www like I was used to do in windows?.
I'm unable to paste the files by using "copy paste click".
Super clear guide, set up with no problems.
Hi! I've been looking at several guides for installing wordpress in ubuntu and yours is really the most in-depth that I've come across, but I'm having some significant problems in configuring phpmyadmin. Yes, I did check the apache2 box with my spacebar, I promise.
I get
error 1045 (28000): Access denied for user 'root@localhost'
at the completion of the reconfigure. I'm wondering if the error could have it's roots in mysql name/password or if I've done something especially silly.
Also, I have tried this:
Edit /etc/apache2/apache2.conf and add the following lines to the end of the file
#for phpmyadmin
Include /etc/phpmyadmin/apache.conf
and when I do the apache2 restart fails, if this additional info is helpful at all. Any comments at all would be appreciated.
@Kirsten - If the phpmyadmin configuration is successful, then the lines you've added to /etc/apache2/apache2.conf are not required and may cause a conflict, so go ahead and undo that change. That may take care of the problem with Apache starting.
I sounds like something may have gone wrong with the phpmyadmin installation. I would try removing it and reinstalling it along with the Apache mod-auth module. Remove it with
and reinstall it with
It should take you through the phpmyadmin configuration again.
If your hunch is correct about your MySQL root password, you can reset it by running
Good Luck!
I was finally able to get through the phpmyadmin install without errors, by following the reinstall steps above. Thank-you. Unfortunately I still don't get anything at http://localhost/phpmyadmin/ not even a 404. Alas. Still, I appreciate your help.
So you're able to access the other http://localhost/ sites?
Leslie's comments below indicate you're not alone. You might want to try completely removing LAMP and try again from the beginning.
Before you do that, you may want to check your /etc/apache2/apache2.conf file and make sure you didn't remove too much. the end of my file looks like this:
Also, my listing of /etc/apache2/conf.d/ is this:
This page might be of some help: https://help.ubuntu.com/community/ApacheMySQLPHP
Thank-you Linerd, uninstalling and starting from scratch did it. You're instructions are incredibly helpful!
I, too, am on the lookout for CLI removal of LAMP in Ubuntu 9.10. Any thoughts or suggestions?
(Thanks, btw, for the guide/tutorial!!)
@Greg- You should be able to do i with something like
I'm not sure of the actual package names, I'm away from my Linux box right now. I'll take a look at it and post an update. After removing the main packages, you can then clean up the rest with
You can also use aptitude instead of apt-get for the first command and the autoremove will be done automatically.
Greg - I figured it out. Take a look at: How To Remove LAMP in Ubuntu.
OK, now that I've installed it. How do I uninstall or remove this lamp-server? It seems everyone is talking about installing it, but I'm not comfortable if I don't know what it installed in my system, I think there are 10-20 packages, how do I remove all of them? Is there a command, a GUI, how do you do it?
I've written a new tutorial on How To Remove LAMP in Ubuntu.
That is a great tut - so clear and easy to follow. With my system, everything worked except the last step. http://localhost/phpmyadmin/ which gives 404 Not Found. What did I do wrong?
Leslie - Did you remember to select "apache2" during the phpMyAdmin configuration like in the picture? Use the Tab key to go to that field and use the Space bar to select it. You can re-run the phpMyAdmin configuration with:
Thanks for answering
Yes, I did do that. I even tried the purge and (re)install (to Kirsten above) in case I had missed something. I still get the same result.
Should I email you? This could go on awhile - I've talked to a couple of others on this already and we are getting nowhere! I really hope you can help :S
Honestly, I have no idea what you might have done wrong. The process has gone smoothly for me every time I've run it. If you want to start over with the install, I just wrote a post on how to uninstall LAMP in Ubuntu. This will purge all of the web server information from your system so you can start fresh.
Good luck.
Leslie - Take a look at my recent reply to Kirsten. It may provide some help.
Thanks. I got it working, and meant to put my reply here, but instead I have put it as a new comment! Sorry about that. My listing of /etc/apache2/conf.d/ is quite different to yours.
[...] under: HowTo, Ubuntu, linux, web development The most popular post on this blog is How to Install LAMP on Ubuntu 9.10. On that post, I've had a few comments asking how to remove the single command LAMP installation. [...]
I started like you mentioned but is one problem
* Starting web server apache2 (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
[fail]
invoke-rc.d: initscript apache2, action "start" failed.
can you help me
Hey, I got it to work. I used
sudo gedit /etc/apache2/apache2.conf
to insert the below code into apache2.conf - at bottom of page.
Include /etc/phpmyadmin/apache.conf
Tut source: http://tolearnfree.blogspot.com/2009/11/how-to-install-apache2-php5-mysql-and.html
then I used your restart apache command, Linerd
sudo /etc/init.d/apache2 restart
Thanks for a superb tut here and thanks also to Mike Kenzie, collector of vintage computers
Are you in Twitter Linerd?
http://www.ncf.ca/~ba600
You are real life savers
Can someone confirm that this guide works with the non-server version of Ubuntu 9.10?
This indeed is a guide for installing LAMP on Ubuntu Desktop. It should work on a server install as well, but I haven't tried it.
This was the best 'how to' that i've come across in a long time.
Thank you.