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. Luther Jeke says:

    Thanks a million!!!

    It was really helpful..... keep up the good work...

  2. Crystal says:

    Howdy,

    I do website development, and I prefer my Linux machines, don't get me started on Bill. However, I followed this through but it puts the files in /var/www/ file which can only be access by the root user. Is there some way to have the www file located where it is read/write capable from regular user not the root? If I just don't understand, I will accept that.

  3. John says:

    Really good article! Thank you very much!

  4. Chethan HR says:

    Really a very useful information and it really helpful to create local web page.........

  5. Dhivya says:

    Its was very useful to know how to install and to work through the server...thanks a lot...

  6. Ivan says:

    Just to say thanks, it was soo easy :D

  7. Diwakar says:

    Excellent tutorial....:) Thank you so much....

  8. Hector Henry says:

    I have contact problem i don't have access or permittion to write on the WWW folder, did any body had that problem? and how to solve it please?

  9. Joaquin says:

    Excellent tutorial, it really helped mi :)

  10. Tiyezx says:

    @Hector
    Create the "www" folder in "var". You probably don't have it thus the problem ur experiencing

  11. Shoeab says:

    Im unableto install phpAdmin when im entering this address "http://localhost/phpmyadmin/." im getting this message
    //
    Not Found

    The requested URL /phpmyadmin/ was not found on this server.
    Apache/2.2.16 (Ubuntu) Server at localhost Port 80
    //
    What should i do?
    And if i have to reinstall it how should i ?

  12. alex says:

    thank you very much. It's a really good explanation!

  13. Emmie says:

    Thanks so much for including the part about using space to select an item. I've been trying to do this using a couple of other articles, and as a newbie I simply didn't know this. Rally great article, thanks!

  14. [...] a nice guide for installing and checking a basic LAMP setup on Ubuntu Share this:TwitterFacebookLike this:LikeBe the first to like this [...]

  15. Savio says:

    That was very helpful.Thanks

  16. mofojo says:

    During install I got:
    "Creating config file /etc/php5/apache2/php.ini with new version
    * Reloading web server config apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName"

    Does this mean //localhost is on 127.0.1.1 rather than 127.0.0.1 ?

  17. mofojo says:

    In phpAdmin I also get this error:
    $cfg['Servers'][$i]['tracking'] ... not OK [ Documentation ]
    Tracking: Disabled

    Is that normal?

  18. mofojo says:

    I need a bit of clarification on the /var/www folder.
    Normally this is a folder with root perms that mirrors "/htdocs" (for MAMP and WAMP) or "/public_html/" on linux servers.
    Norrmally one does not put the web page files in /www but in /htdocs or /public_html ... leaving /www to serve the mirrored content.
    Is this not the case with LAMP ?

  19. Leon says:

    Thanks a bunch, great how to =)

  20. Faz says:

    Great and thanks for sharing

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>