Install LAMP and phpMyAdmin on Ubuntu 11.10

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.

[term]sudo apt-get install lamp-server^[/term]

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.

[term]echo “<?php phpinfo(); ?>” | sudo tee /var/www/testing.php[/term]

Enter your password if prompted.

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

[term]sudo service apache2 restart[/term]

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.

[term]cat /etc/hosts | grep localhost[/term]

You should see output something like this:

[term]

127.0.0.1    localhost
::1     ip6-localhost ip6-loopback

[/term]

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

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

You should see output like this.

[term]

bind-address        = 127.0.0.1

[/term]

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

90 thoughts on “Install LAMP and phpMyAdmin on Ubuntu 11.10

  1. Manish Kumar

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

    Reply
  2. Dinesh

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

    Reply
  3. Craig Rothfuss

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

    Reply
    1. Linerd Post author

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

      Reply
  4. Mahmoud

    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

    Reply
    1. Linerd Post author

      /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:
      [term]gksudo nautilus –no-desktop[/term]

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

      Reply
  5. Vijay Vyas

    Hello sir i m using the ubuntu 11.10 with Apache/2.2.20 (Ubuntu) with php5.
    I have problem with urlrewriting, i want to use .htaccess file but i dont know how to give permission…
    Thanking u in advance…

    Reply
  6. Chris

    Thank you so much! This is by far the best walk-through I have found so far. I’ve been wasting away for hours trying to troubleshoot some things, but a couple minutes reading this page seems to have fixed everything.

    Reply
  7. Don

    YES! Done. needs
    sudo /etc/init.d/apache2 restart
    after, and that’s it.

    Thanks for your help. We beginners need all the help we can get.
    Cheers

    Reply
  8. Don

    That’s a valuable piece of research. I’ll file it away. Thanks very much.
    I actually un-installed the lamp-server and re installed it and this time it went through the password stage. I can log in to mysql as root.

    HOWEVER I can’t get phpmyadmin to be found on localhost. Error 404
    I already un and re installed it and re configured it once. I’ll try again.
    Thanks in advance for any future advice.

    Reply
    1. Linerd Post author

      If you’re sure you’ve configured it correctly, try clearing your browser cache. I’ve had problems with Firefox especially. Once you get the 404 error, Firefox doesn’t really try to reload the page from the server. It just reloads from the cache. Firefox has had me chasing my tail more times than I can think of. Maybe that’s why the logo is a fox chasing its tail 🙂

      Reply
      1. Don

        That’s a good thought. I cleared Firefox of all history, cache, cookies, the lot. But the problem persists.
        phpinfo() works but not phpmyadmin. It works okay on my laptop with U10.10?
        “URL not found on this server” ? Got to be something basic.

        Reply
      2. Don

        That’s a good thought. I have now cleared the cache in Firefox but still the problem persists.
        error 404 url phpmyadmin not found on server.
        I might try this one and see what happens.
        sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf.d
        What do you think?

        Reply
  9. Don

    Hi there. I wasn’t prompted for a password after the first step. Now I can’t connect to mysql. I get permission denied to root @localhost password = no/yes (I tried my sudo password.)
    Apache and php are working and mysql is running.It’s just the password issue for mysql.
    What’s up? Should I uninstall lamp and try again. I used “sudo apt-get install lamp^”

    Reply
    1. Linerd Post author

      After a little bit of research, I’ve found that you can reset the MySQL root password by reconfiguring the installation with this command:
      [term]sudo dpkg-reconfigure mysql-server-5.1[/term]
      You should then get prompted to enter a new password, and then confirm the new password.

      Reply
  10. Sunny George Michael

    Please, don’t worry because I have figured it out. I can now access phpmyadmin. The only problem now is that when I want to create a new database, I will get a message that says; ‘No privileges”. Please, what could be responsible for that and how can I create a new database?

    Thanks.

    Sunny

    Reply
    1. Linerd Post author

      The password that you created for phpMyAdmin during installation was for the root user. Are you logging in as root? Root should have full administrative access and be able to create and delete databases.

      Reply
  11. Sunny George Michael

    Hi!

    Following your instructions, I successfully installed LAPM on my system using Ubuntu 11.10. Tested everything and it worked, but when I open myphpadmin, I was prompted to enter my username and password, I did, but got this message: “#1045 Cannot log in to the MySQL server’. What could be the problem because I remember during installation I was only asked to enter my password alone. Please, what do I do?

    Thanks.

    Sunny

    Reply
  12. zaqueu

    hi!
    thanks for helping me with this tutorial, now my phpadmin is running without any kind of problem. So God bless u in everything u do.
    i say it again, THANK YOU!!!

    Reply
  13. srikrishnan

    I want to create & use cgi and pl files in my lamp environment. If that also has been added with this tutorial then I think this tutorial would be complete. Yesterday I installed LAMP successfully without any problem as per this tutorial.

    Reply
    1. Linerd Post author

      Thanks for the feedback. I’m not much of a web developer, so I haven’t really messed with that, but I’ll look into it. 🙂

      Reply
  14. lightswitch

    Wow. Tutorial ran perfectly. Needed recent version of PHP and MySQL to do development and this got me started quick.

    Thanks again

    Reply
  15. srikrishnan

    Thanks for this clean and elaborate step by step instruction for installing LAMP in our Ubuntu 11.10 OS. As a learner of Web Designing this page is very useful for us. I have installed LAMP without encountering any error as per the procedure given in the page.

    Reply
  16. mitch

    how do u change the name of a file it keeps telling me that i dont hav the permissions to do so……?

    Reply
    1. Linerd Post author

      You can use the mv command from the terminal. Since you don’t have permission you will need to use sudo.
      [term]sudo mv name1 name2[/term]

      Reply
  17. Steve MacEwan

    Have been running Lampp for a few months now and I always got the
    “apache2: Could not reliably determine the server’s fully qualified domain name,
    using 127.0.1.1 for ServerName”, with no problems running PHP with Zend framework.

    The echo “ServerName localhost” | sudo tee /etc/apache2/conf.d/fqdn”, worked for me a treat… Thanks for that…

    For anyone wanting to install Lampp under Ubuntu 11.10, this is the only tutorial you should need…

    Thanks again…

    Reply
  18. Param Lowe

    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
    .

    Reply
  19. Param Lowe

    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

    Reply
  20. bhuwan

    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

    Reply
  21. old.graham

    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.

    Reply
  22. shefali

    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^’

    Reply
  23. sugiono

    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

    Reply
  24. heshanhhh

    I was searching this for 3 days. Thanks very much ..!! problem was 404 not found .!! now it’s sorted.! 100% working.

    Reply
  25. ARULSELVANAR M

    Thanks a lot! A very informative article which made easy the LAMP installation within short time;Can you please add squirrelmail server also

    Reply
  26. sean

    download and install lamp on ubuntu 11.10 done easy.

    terminal in ubuntu 11.10 is accessed by pressing ctrl + alt + T.

    installation done!!

    Reply
  27. .Todd

    Would you be willing to do an article like this for a LAPP (Linux Apache PostgreSQL PHP) server install? It would be great if there was a sudo apt-get install lapp-server^ option.

    Reply
  28. .Todd

    Thanks, great article! I particularly like the sudo apt-get install lamp-server^ information and the fix common problems with phpmyadmin because that is exactly what I did wrong. Oh, the tee command was nice too! 🙂

    Reply
  29. sandra

    all went smoothly, thanx a bunch, except the last bit. i got this error.
    tanuwa@tanuwa-Satellite-L310:~$ echo “ServerName localhost” | sudo tee /etc/apache2/conf.d/fqdn
    ServerName localhost
    tanuwa@tanuwa-Satellite-L310:~$ service apache2 reload
    * Reloading web server config apache2 ulimit: 88: error setting limit (Operation not permitted)
    httpd not running, trying to start
    (13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
    no listening sockets available, shutting down
    Unable to open logs
    Action ‘graceful’ failed.
    The Apache error log may have more information.
    [fail]

    Reply
    1. Linerd Post author

      Oops. I forgot to include a sudo before the last command. It should read
      [term]sudo service apache2 reload[/term]
      Thanks for your comment. I’ll fix the instructions.

      Reply
  30. Don

    Excellent help many thanks.

    Not 100% sure of Ubuntu 11.10, much prefer 10.04. but I guess I’ll get use to it…

    Don 🙂

    Reply
    1. Linerd Post author

      Yeah, I’m still using 10.04 as my main desktop. I can’t stand Unity, so I’ve installed the fallback session on 11.10.

      Reply
    1. Mizan

      I think that you did not press for this step “Make sure to then mark apache2 by having the cursor next to apache2 and then hitting to mark it with a *, then hit .”

      plz repeat this portion
      “Fixing some common problems
      Fixing phpMyAdmin” from the above link

      I had same issue like u

      Reply
  31. JP

    Thanks for the common fixes bit. I forgot to select the Apache2. Maybe you should write that the user should click the spacebar in the Tut for those of us who are new to Ubuntu Server.
    thanks again.

    Reply
  32. Danny Cheeseman

    A+!! Cheers for this.. Very simple walk through.. Also, thank you for the 404 fix for phpmyadmin! When I first installed I assumed that apache2 was already selected due to the red box.. Who would have thought to press space!!!

    Reply

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.