Install LAMP and phpMyAdmin on Ubuntu 11.10

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

Page 1 Page 2

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

Click to enlarge

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.

Page 1 Page 2

Comments

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

  1. bryan says:

    it works..thanks

  2. Mahmoud says:

    it works fine , Thank you
    but i can not create any files using the GUI, i mean when i be in the /var/www i can not create any file

    • Linerd says:

      /var/www is owned by root, so you either need to change the ownership to yourself, or you could start a file manager as root. Assuming you use regular Ubuntu, you can launch the Nautilus file manager with root permissions with:

      gksudo nautilus --no-desktop

      Another option is to put your files in a folder under your user ID and configure Apache to load them from there.

  3. Gersonup says:

    Gracias muy amable, me sirvió mucho..
    thank u very much, this was utility

  4. jorge diaz says:

    buenisima la explicacion. instalacion completa gracias a esto.

    great explication, thank you.

  5. Craig Rothfuss says:

    Great tutorial, thanx! One question - does an FTP server get installed with the lampserver install? Or does it have to be set up separately?

    • Linerd says:

      I don't believe that an ftp server gets installed with this process, so you will have to do that separately.

  6. mchillair says:

    Great piece there. Thanx a lot.

  7. Dinesh says:

    If you are facing some problem with phpmyadmin then consult this post [http://codesprints.blogspot.in/2012/04/phpmyadmin-not-working-ubuntu.html].

  8. ber says:

    worked very well !!!! Thanks for your help !!!!!

  9. werkenmapu says:

    Thank you, All Ok. Now Im want to install PHPMYADMIN

  10. trellis says:

    thank you so much for your help!! Your troubleshooting section was a very nice addition

  11. francis visitacion says:

    thank you! Perfectly Working...

  12. Manish Kumar says:

    Works perfectly, thanks!
    To install phpmyadmin, Just run the command in the terminal
    sudo apt-get install lamp-server^ phpmyadmin

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>