Installing LAMP on Ubuntu 10.04 and 10.10 (Lucid Lynx, Maverick Meerkat)

April 29, 2010 by
Filed under: HowTo, linux, Ubuntu, web development 

Page 1 Page 2

If you're developing websites, it's nice to be able to test your code in the privacy of your own computer rather that out in the public internet. In order to do that, you'll need to install a web server on your development computer. LAMP (Linux, Apache, MySQL, php) is one of the most common web hosting platforms, so it's a perfect environment for you to build and test your website code. If you carefully follow these step by step instructions, you'll have your own Ubuntu LAMP web server on installed, configured, and running in no time. 

Install LAMP Web Server on Ubuntu

The Ubuntu developers have made it easy to install and configure the LAMP server packages with a single command. Simply open a terminal window and enter the following.

sudo apt-get install lamp-server^

No, that's not a typo. Please make sure to include the caret (^). The command will not work without it.

sudo apt-get install lamp-server^

sudo apt-get install lamp-server^

The apt package manager will show all the packages that need to be installed. Hit <Enter> to confirm that you want to install them.

LAMP packages

LAMP packages

You will then be prompted to change the password for the root user on the MySQL database.

Set MySQL root password

Set MySQL root password

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 now complete! That was the easy part, now you need to get a few things configured to make your 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 Apache

Testing Apache

Test php

Now that you know Apache works, you'll want to test the php installation. You'll need to create a file in /var/www called testing.php. Open a terminal and enter:

sudo nano /var/www/testing.php

Enter the following line into the text editor, save the file and exit.

<?php phpinfo(); ?>

Next, restart Apache with the following terminal command:

sudo /etc/init.d/apache2 restart

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.

php Information

php Information

Configure MySQL

Since I'm installing LAMP for a web development environment, I want the MySQL database to be bound to the localhost IP address. This should be 127.0.0.1 for your system. You can verify it with this terminal command.

cat /etc/hosts | grep localhost

You'll now want to verify that the correct bind address is set up in MySQL's my.cnf file.

cat /etc/mysql/my.cnf | grep bind-address

You should see a line that looks like this:

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.

Page 1 Page 2

Comments

499 Responses to “Installing LAMP on Ubuntu 10.04 and 10.10 (Lucid Lynx, Maverick Meerkat)”

  1. MaxPayne says:

    thanks a lot!

  2. Pavan Naidu says:

    Thanks a lot its awsome

  3. hicham says:

    merci monsieur !

  4. chima says:

    this site was really a helpful guide to me. thanks

  5. Coleen says:

    Thank you.

  6. Johnny says:

    Thanks, it works perfect.

  7. Andrew says:

    Thanks a bunch!! You made it a cinch for this Ubuntu newb!

  8. ken says:

    thank you

  9. abraham says:

    Thanks a Lot

  10. dever says:

    Thank you for putting this together. Works perfectly!

  11. homina says:

    Thanks a lot.....

  12. zoe says:

    Just what I was looking for. Thanks.

  13. Rajgopal H.G. says:

    Excellent documentation.
    Even a kid can install LAMP server by reading this document.
    Thanks for your efforts.

  14. Stormy says:

    Wow am I glad I came upon this doc. it was excellent and painless, a job well done in putting this together.

  15. yasin says:

    thanks alot for guiding me to install lamp.....
    and to configure it

  16. Freddy says:

    I cannot seem to install the phpmyadmin.
    The error message I get is
    $ sudo apt-get install libapache2-mod-auth-mysql phpmyadmin
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Couldn't find package phpmyadmin

    I get this even if I do sudo apt-get update

    Any help as to how I can install phpmyadmin would be great.

    • Linerd says:

      The package database may be in the midst of an update. You could wait and try again later, or you could try changing your software sources to a different mirror. For example, if your system is set to load packages from the Ubuntu Main server, try changing to the Server for The United States. Then of course do another update before you try the install.

  17. Gi says:

    THANKS !!!

  18. Gerald says:

    Saved a lot of time. I've always installed the stack manually! A simple claret (^) makes all the difference - and I don't mean the drink!
    Thank you very much for your expertise.
    Gerald.

  19. paopaomj says:

    Thanks a lot!!! :-D

  20. maor says:

    Not working :(

    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Couldn't find package lamp-server

    Why...?

    • Linerd says:

      Make sure to include the ^ at the end of the command. The command should be

      sudo apt-get install lamp-server^
      • maor says:

        yep, I did that... How to add/change resources/servers for download?

        • Linerd says:

          You can change your servers from Synaptic. Open the Synaptic Package Manager and go to Settings->Repositories. In that menu there is a drop-down list labelled Download from:. The choices there are: Main server, Server for United States, Other. The "Other" list will give you a choice of all available mirrors for the repositories. When you use the "Other" option, there is also a button to Select Best Server. That will figure out the fastest server for your location.

          After selecting a new server you'll need to update your package lists. Either hit "Reload" from the main Synaptic window or from the command line:

          sudo apt-get update

          Then try the LAMP install again.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>