Install LAMP and phpMyAdmin on Ubuntu 11.10

October 23, 2011 by
Filed under: HowTo, linux, Ubuntu, web development 

Page 1 Page 2

Sponsors

LAMP stands for Linux, Apache, MySQL, and php, (or Perl). It's one of the most popular web hosting platforms. If you're developing websites, it's good to have your own private development environment to use while you build and test your websites. This post will show you how to install and configure a LAMP web development environment on Ubuntu 11.10 Oneiric Ocelot to use for testing. It can also be used to set up LAMP on a Virtual Private Server (VPS) or a Dedicated Server, but please note that this post does not cover setting up proper security for serving content to the internet.

Install LAMP

The Ubuntu development team has made it very easy to install and configure a LAMP web server. Open a terminal window and enter the following command.

sudo apt-get install lamp-server^

Please enter the command exactly as it's shown above. The carat (^) is not a typo and the command will not work without it.

Command to install LAMP

If prompted, enter your password.

The package manager will now display a list of packages to be installed. Hit <Enter> to confirm that you want to go ahead with the install.

Installing LAMP packages

Click to enlarge

Apt will now start downloading and installing the packages on your computer.

After a short wait, you will be prompted to set a password for MySQL's administrative user. Enter a password at the prompt and make sure it's something you will remember or make a note of it.

MySQL password

Click to enlarge

You will then be prompted to confirm your password.

Confirm MySQL password

Click to enlarge

Type in the same password and hit <Enter>. The package manager will now continue downloading and installing packages. After a short wait the installation will complete.

Testing Apache

Now we'll run a quick test to make sure that the Apache web server is working. Open a web browser and enter the address http://localhost/. You should see a page that says "It Works!"

Testing Apache installation

Click to enlarge

Testing php

Now that we've verified that Apache works, we need to verify that php is working properly. We're going to create a file in the /var/www directory called testing.php. Enter the following command in the terminal to create the file.

echo "<?php phpinfo(); ?>" | sudo tee /var/www/testing.php

Enter your password if prompted.

Now you'll need to restart the Apache web server. Enter into the terminal:

sudo service apache2 restart

Now open your web browser and enter the following address: http://localhost/testing.php

You should see a web page that displays a bunch of information about your php and Apache environment.

Testing php

Click to enlarge

Configure MySQL

Since this is for a local development environment, the MySQL database needs to be bound to the localhost IP address. This should be 127.0.0.1 by default. You can verify your localhost address with the following terminal command.

cat /etc/hosts | grep localhost

You should see output something like this:

127.0.0.1    localhost
::1     ip6-localhost ip6-loopback

Now you need to verify that this address is the bind address MySQL's my.cnf file. Use the following terminal command.

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

You should see output like this.

bind-address        = 127.0.0.1

If it's not correct you'll need to edit /etc/mysql/my.cnf as root to fix it.

Sponsors

Page 1 Page 2

Comments

90 Responses to “Install LAMP and phpMyAdmin on Ubuntu 11.10”

  1. Karthik says:

    Thanks a lot....

  2. sugiono says:

    hi,

    I am trying to have LAMP / server installed on my laptop so I can test php. I followed each of the step and passed all the test above.

    When i try to install php web package , it shows blank page.

    can you pls advise what went wrong? thanks

  3. shefali says:

    i am getting this error every time i try
    plz help
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package lamp-server^
    E: Couldn't find task 'lamp-server'
    E: Couldn't find any package by regex 'lamp-server^'

  4. twizol says:

    Thank you !!

  5. Abdullah says:

    thanx for this usefull tutorial

  6. onrdisan says:

    Thank you for this detailed info

  7. old.graham says:

    For all that I have peformed this install several times over the last 3 years, I STILL forget to leave the asterisk when configuring the phpmyadmin. Thanks for the reconfigure advice or I would have been scratching my head for days; and thanks to them as what take the time to post this install advice which makes my life so easy.

  8. pael says:

    thank you so much for this detailed guide. :) )

  9. xochoa says:

    Much appreciated =)

  10. A.Bhatnagar says:

    Really helpful. Thanks a lot :-)

  11. Sol72 says:

    Finally..Ur info was right on. Owe u a beer one day...

  12. bhuwan says:

    Thanks you have done great job :) .

    I have configure LAMP web development environment successfully. but i am getting a error message in the phpmyadmin. that is as

    connection for controluser as defined in your configuration failed.

    Thanks

  13. petert says:

    Thank you! Up and running in just a few minutes.

  14. Param Lowe says:

    Hi

    Thanks for such a detailed tutorial on installing Local AMP on ubuntu 11.10.
    I recently moved to ubuntu 11.10 and followed it step by step and it worked like a charm.
    Thanks once again.

    - Param
    Nothing can match the moral boost one gets with Open Source & GPL OS

  15. Param Lowe says:

    Got one problem. When I try to make new folder or file in www folder ubuntu error pops up :
    " Could not save the file /var/www/newfile.html
    You do not have the permissions necessary to save the file. Please check that you typed the location correctly and try again. "

    Now if we can not create new folder or file then how can we develop webs in there... lol
    any help to mend this issue will be appreciated
    .

  16. Param Lowe says:

    solution found at http://ubuntuforums.org/showthread.php?t=1694505
    to get ownership of directory with command
    sudo chown /var/www
    DONE!

  17. dentscyber says:

    1. type on terminal -> sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf.d

    THEN

    2. sudo /etc/init.d/apache2 restart
    3. WORKS !!!
    this is if you can't access http://localhost/phpmyadmin

  18. dhowe says:

    Thank You! Your instructions worked to a "T". You made the process easy.

  19. autthapone says:

    Thank a lot for Fixing phpMyAdmin solution :-)

  20. ahmed says:

    Great info thanks for the 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>