Installing LAMP on Ubuntu Jaunty (9.04)

June 6, 2009 by
Filed under: HowTo, linux, Ubuntu, web development 
Sponsors

For the latest version, check out Install LAMP on Ubuntu 9.10 Karmic Koala.

Why Install LAMP?

Today I'm going to show how to install and set up a LAMP (Linux, Apache, MySQL, PHP) stack on Ubuntu. Why do this? It's useful if you want to set up an off-line web development environment. If you are building websites and experimenting, it's nice to do it in the privacy of your own computer, rather than "in the wild" out on the internet.

Install LAMP

Ubuntu has an easy way to select and install all of the required packages. It's done with the following command.

sudo apt-get install lamp-server^

Don't forget to include the carrot. According to the Ubuntu documentation, it's magical.

Hit <Enter> to confirm you want to install the packages.

apt-get install lamp_server

apt-get install lamp-server

Next, you will be prompted to change the password for the root user on your MySQL database.

Change root Password in MySQL

Change root Password in MySQL

Enter your chosen password. Enter it again in the confirmation screen.

After some more chugging in the terminal the installation will complete.

LAMP Installation Complete

LAMP Installation Complete

Now we need to test the installation and get things configured.

Testing Apache

Open a web browser and enter the address http://localhost/.  You should see a webpage displaying the text "It Works!"

Testing Apache - It Works!

Testing Apache - It Works!

Testing PHP

Now we're going to test our PHP installation. To do this we'll create a file called testing.php in /var/www. Open a terminal and enter:

gksudo gedit /var/www/testing.php

Enter the line below, save the file, and exit the text editor.

<?php phpinfo(); ?>

Now we need to restart Apache.

sudo /etc/init.d/apache2 restart

Now, open your browser and enter http://localhost/testing.php/. You should see a bunch of information about your version of PHP.

Testing PHP Installation

Testing PHP Installation

Configuring MySQL

Now we need to configure MySQL to be associated with the IP address of your machine. Since I'm installing the LAMP stack for a web development environment I'm going to bind MySQL to the localhost IP address, which in my case is 127.0.0.1. You can verify this address with:

cat /etc/hosts | grep localhost

Edit the my.cnf file to configure the bind address.

gksudo gedit /etc/mysql/my.cnf

Verify that the bind-address line looks like this (adjust for your IP address).

bind-address = 127.0.0.1

Install phpMyAdmin

This step is optional, but phpMyAdmin will make it much easier to administer the MySQL databases.

sudo apt-get install libapache2-mod-auth-mysql phpmyadmin

During the installation you will be prompted to select your web server for automatic configuration. Use the space bar to mark apache2 and then hit <Enter>.

You will also be asked if you want to configure phpMyAdmin with a new database called dbconfig-common. Select Yes and hit <Enter>.

Configure phpmyadmin with dbconfig-common

Configure phpmyadmin with dbconfig-common

Next you'll be prompted for the password for MySQL's administrator. Enter the MySQL root password that you created earlier in the installation. Hit <Tab> to select Ok and hit <Enter>.

Next you'll be prompted to create an application password for phpMyAdmin to talk to MySQL. If you leave it blank, a random password will be generated for you.

After configuring the password, the installation should complete.

Testing phpMyAdmin

Enter http://localhost/phpmyadmin/ into your web browser. You should see a page that looks like this:

Testing phpMyAdmin Installation

Testing phpMyAdmin Installation

You should be able to log in using the username root and the root password that you created earlier.

Logged In To phpMyAdmin

Logged In To phpMyAdmin

Your LAMP installation is now complete.

At this point you may want to do some additional Apache configuration.

Sponsors

Comments

54 Responses to “Installing LAMP on Ubuntu Jaunty (9.04)”

  1. Sayantan Das says:

    thanks a lot. this is the easiest ,shortest, and quickest way to install LAMp....
    no hassles. thanks again.

    just a small thing... i think, for phpmyadmin to start on the browser, u have to add this line in /etc/apache2/apache2.conf

    #for phpmyadmin
    Include /etc/phpmyadmin/apache.conf

    • Linerd says:

      Sayantan - Thanks for the comment. I didn't have to make any changes to /etc/apache2/apache2.conf. In fact, I just went and checked that file and there is no phpmyadmin line in there. Perhaps your setup is different from mine. I imagine other Linux distros handle things a bit differently.

      I went through all of this just yesterday on a fresh install of Jaunty, using the latest packages. I haven't tried this yet on my Hardy install. You're edit may come in handy there.

  2. [...] LAMP (  Thnks to Linerd) [ For those who are afraid of the terminal, Each of these softwares can be installed from [...]

  3. Michael says:

    Thanks so much for sharing this easy LAMP install, I just followed your step by step instructions to install LAMP, but when I installed and tried to login phpMyAdmin, I got an error message: Access denies, I did not enter password for MySQL (blank) but I did enter the password for phpMyAdmin, and to login phpMyAdmin, I used root as you said, and the password I created, what have I done wrong?

    Thanks,
    Michael

  4. BR says:

    Try using the MYSQL password you created in the early part of the process, rather than the PHPMyAdmin password you just created..that worked for me..

  5. Frans van Leeuwen says:

    Good information. However, al my browsers don't accept a php-file for output. The all ask the question what I want tot do with such a file.

  6. Rexedead says:

    Thanks!

  7. Aumi says:

    hi, nice tutorial... i've installed it successfully.... thanks a lot

  8. [...] ! (mais on peut aussi installer phpMyAdmin pour compléter le tout) This entry was posted in Aventures ordi-naires and tagged Ubuntu. [...]

  9. Lipu says:

    I have to add this line too.

    #for phpmyadmin
    Include /etc/phpmyadmin/apache.conf

  10. Darksoul says:

    Emm... at Install phpMyAdmin.. I type

    sudo apt-get install libapache2-mod-auth-mysql phpmyadmin

    but I suddenly choose apache...how to fix it..i want to choose apache2...help me..I'm newbis

    • Linerd says:

      @Darksoul - Do you mean you selected the wrong thing during installation of phpmyadmin? Yo can re-run the configuration with:

      sudo dpkg-reconfigure phpmyadmin
  11. john says:

    Thanks a bunch I went through several tutorials and none worked untill this one. The only thing missing is you didn't tell them to restart apache before checking php..

    Thank
    John

  12. localhost says:

    shot dude! nice post, seamless and easy install thanks to you!

  13. Sathish says:

    Simple but great tutrorial

    THanks a lot !!!

  14. Yves says:

    Nice tutorial, worked like a charm.
    Thank you!

  15. ryan says:

    excellent tutorial.
    exactly what i wanted to do and it doesn't get any easier

  16. Zulfir Sadat says:

    Wonderful Tutorial
    Great contribution. Thanks a mollion

  17. tom smith says:

    By far the best thought through set of instructions I have found to date. Thank you!

  18. Mike M. says:

    NICE! This is hands down the easiest to follow LAMP install that I have found, great job.

    BTW - I, too, had to add the lines:

    #for phpmyadmin
    Include /etc/phpmyadmin/apache.conf

    at the end of my apache2.conf file. and the RESTART apache and I was good to go!

    Thanks again..

    Mike

  19. Yoav Givon says:

    Perfect , clean installation , no one single problem . Thanks a million

  20. latulipe says:

    a very good tutorial... until i tried to access phpMyAdmin. There was a problem with te ,my.cnf' file. i did as written the gksudo gedit /etc/mysql/my.cnf manip.
    can i delete MySql without touching PHP and Apache because they are still ok.
    thanks

    • Linerd says:

      latulipe - The easiest way may be to open Synaptic and search on the installed Mysql packages. Mark them for complete removal (this is supposed to get rid of all settings/preferences files as well) and then go ahead and reinstall those same packages.

  21. Sooraj says:

    thanks for the easy tutorial.

  22. Abhinand says:

    Help!

    After installing phpmyadmin, I'm getting a 404 ERROR when I open http://localhost/phpmyadmin/ . It is saying that phpmyadmin was not found on this server.

    The remaining LAMP installation was successful.

  23. Abhinand says:

    I found a work-around for the 404 ERROR from the ubuntuforums.
    Thanks.

  24. Rick Wilson says:

    Thanks, this was the easiest nethod I have come across. Thanks for shareing this with us. I can remember this taking me hours about a year ago. Good job!

  25. bhuvana says:

    sir,

    i m getting err like
    E: could not get lock/var/lib/dpkg/lock -open(11 resource temporarily unavailable)
    E: unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

    • Linerd says:

      Bhuvana, it sounds like a package manager was already running when you tried to do the install. Was the update manager running at the time? The install may work if you just try it again.

  26. libripens says:

    I also ran into the problem of my browser not finding http://localhost/phpmyadmin .

    I solved the problem by typing this in Terminal:
    sudo ln -s /usr/share/phpmyadmin /var/www

    I tried it, and it worked.
    This solution was written by TitanKing in the comments section of this post: http://ubuntuforums.org/showthread.php?t=1036836

    Great guide! Thank you. I'm going to tweet it!

  27. Benjamin Russell says:

    Those of you who are finding that PhpMyAdmin will not run directly after installation are skipping over a key line in this tutorial:

    "Use the space bar to mark apache2 and then hit ."

    You must hit the space bar to mark the "apache2" option with a little asterisk before hitting .

    Admittedly, it's kind of a confusing interface.

    • Linerd says:

      Benjamin - Thanks for the tip.

      Everyone - If you forgot to mark apache2 during the phpMyAdmin configuration, you can re-run this step with the command
      sudo dpkg-reconfigure phpmyadmin

  28. Erik Vandamme says:

    Great article, but none of the steps asked for a password and now
    http://localhost/phpmyadmin
    I get the following message after http://localhost/phpmyadmin
    #1045 - Access denied for user 'root'@'localhost' (using password: YES)

    or when i do different tests
    #1045 - Access denied for user 'root'@'localhost' (using password: YES)

    where can I find what is in Connection for controluser as defined in your configuration failed.

  29. Erik Vandamme says:

    Thanks Linerd. Problem solved used
    sudo dpkg-reconfigure phpmyadmin

  30. Keller says:

    Thank you ever so much. My Comp Engineering teacher wanted a LAMP up and running and this was so easy I had it done in an hour including installing Ubuntu. I can't thank you enough.

  31. ameen says:

    it really nice .. i search on many sites but this page provide my need.. thamku!

  32. Live says:

    OK, now that I've installed it. How do I uninstall or remove this lamp-server? It seems everyone is talking about installing it, but I'm not comfortable if I don't know what it installed in my system, I think there are 10-20 packages, how do I remove all of them? Is there a command, a GUI, how do you do it?

  33. anshu says:

    superb tutorial!!!

  34. Derek says:

    When I go through the configuration of the db for phpmyadmin, I get this error:

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

    An suggestions?

  35. Al Mubarak says:

    Hai.,

    i had linux 9.04 Jaunty jackalope Os and now i developed my website designs in PHP platform. now i installed LAMP SERVER by the above instruciots. but whenever i pink my http://localhost in browser it displays like that below.,

    Forbidden

    You don't have permission to access / on this server.
    Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.5 with Suhosin-Patch Server at localhost Port 80

    Anyone could known to rectify this issue.

    Thanks in ADVANCE

  36. Raj says:

    Hi

    When I tried the first step, the browser automatically points to http://localhost/mythweb/
    then gives the following error message

    Error

    Unable to connect to the master backend at 10.0.1.3:6543.
    Is it running?

    Everything else seem to run fine. Thanks heaps for the excellent tutorial series.
    cheers
    Raj

    • Linerd says:

      It looks like you have MythTV installed on your system. I'm not familiar with Myth, but it seems like you might need to make some minor adjustments.

  37. Raj says:

    Thank you very much.
    I went to Synaptic package manager and completely removed Myth TV and all its associated components. It works! Look forward to your next tutorial. Thanks again!
    Raj

  38. alvin says:

    I forgot the password in my phpmyadmin.. how can i retrieve it?

  39. the only thing I would add is
    ubuntu:~/Sites/projects$ sudo a2enmod rewrite
    Enabling module rewrite.
    Run '/etc/init.d/apache2 restart' to activate new configuration!

    For clean URLS and drupal

  40. works like a charm! thanks. sweet and simple, eh!
    - niyam

  41. Noddy says:

    Thanks for this, just tested it on Xubuntu 12.04 and everything works fine.

    Used leafpad instead of gedit for the text editor. leafpad is the default text editor on Xubuntu.

  42. Zishan rana says:

    I`m facing that error

    root@zishan-desktop:~# sudo apt-get install libapache2-mod-auth-mysql phpmyadminReading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following extra packages will be installed:
    dbconfig-common javascript-common libjs-mootools libmcrypt4 libt1-5 php5-gd
    php5-mcrypt wwwconfig-common
    Suggested packages:
    libmcrypt-dev mcrypt postgresql-client apache apache-ssl
    The following NEW packages will be installed:
    dbconfig-common javascript-common libapache2-mod-auth-mysql libjs-mootools
    libmcrypt4 libt1-5 php5-gd php5-mcrypt phpmyadmin wwwconfig-common
    0 upgraded, 10 newly installed, 0 to remove and 186 not upgraded.
    E: Could not get lock /var/cache/apt/archives/lock - open (11: Resource temporarily unavailable)
    E: Unable to lock the download directory

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>