Installing LAMP on Ubuntu Jaunty (9.04)

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

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.

Comments

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

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

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

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