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. Steve MacEwan says:

    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...

  2. mitch says:

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

    • Linerd says:

      You can use the mv command from the terminal. Since you don't have permission you will need to use sudo.

      sudo mv name1 name2
  3. Ganesan K says:

    Thanks for sharing nice article, about lamp and php.

  4. srikrishnan says:

    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.

  5. lightswitch says:

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

    Thanks again

  6. srikrishnan says:

    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.

    • Linerd says:

      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. :)

  7. zaqueu says:

    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!!!

  8. Sunny George Michael says:

    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

  9. Sunny George Michael says:

    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

    • Linerd says:

      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.

  10. Don says:

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

    • Linerd says:

      After a little bit of research, I've found that you can reset the MySQL root password by reconfiguring the installation with this command:

      sudo dpkg-reconfigure mysql-server-5.1

      You should then get prompted to enter a new password, and then confirm the new password.

  11. Don says:

    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.

    • Linerd says:

      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 :)

      • Don says:

        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.

      • Don says:

        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?

  12. Don says:

    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

  13. kenpachi123 says:

    your username is root and your password is what they asked before you installed the LAMP

  14. Chris says:

    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.

  15. yudha says:

    yay....
    it works !!!!
    great !!!!
    tq so much

  16. Aitor Bergara says:

    very good, thank you very much

  17. Vijay Vyas says:

    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...

  18. Yene says:

    very nice work here.

  19. danielg28 says:

    WERY GOOD
    Dzi?ki !!!!!

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>