There is a new version of this tutorial available for Ubuntu 18.04 (Bionic Beaver).

Installing Apache2 With PHP5 And MySQL Support On Ubuntu 9.10 (LAMP)

Version 1.0
Author: Falko Timme
Follow me on Twitter

LAMP is short for Linux, Apache, MySQL, PHP. This tutorial shows how you can install an Apache2 webserver on an Ubuntu 9.10 server with PHP5 support (mod_php) and MySQL support.

I do not issue any guarantee that this will work for you!


1 Preliminary Note

In this tutorial I use the hostname with the IP address These settings might differ for you, so you have to replace them where appropriate.

I'm running all the steps in this tutorial with root privileges, so make sure you're logged in as root:

sudo su


2 Installing MySQL 5

First we install MySQL 5 like this:

aptitude install mysql-server mysql-client

You will be asked to provide a password for the MySQL root user - this password is valid for the user [email protected] as well as [email protected], so we don't have to specify a MySQL root password manually later on:

New password for the MySQL "root" user: <-- yourrootsqlpassword
Repeat password for the MySQL "root" user: <-- yourrootsqlpassword


3 Installing Apache2

Apache2 is available as an Ubuntu package, therefore we can install it like this:

aptitude install apache2

Now direct your browser to, and you should see the Apache2 placeholder page (It works!):

Apache's default document root is /var/www on Ubuntu, and the configuration file is /etc/apache2/apache2.conf. Additional configurations are stored in subdirectories of the /etc/apache2 directory such as /etc/apache2/mods-enabled (for Apache modules), /etc/apache2/sites-enabled (for virtual hosts), and /etc/apache2/conf.d.


4 Installing PHP5

We can install PHP5 and the Apache PHP5 module as follows:

aptitude install php5 libapache2-mod-php5

We must restart Apache afterwards:

/etc/init.d/apache2 restart


5 Testing PHP5 / Getting Details About Your PHP5 Installation

The document root of the default web site is /var/www. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.

vi /var/www/info.php

Now we call that file in a browser (e.g.

As you see, PHP5 is working, and it's working through the Apache 2.0 Handler, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP5. MySQL is not listed there which means we don't have MySQL support in PHP5 yet.


6 Getting MySQL Support In PHP5

To get MySQL support in PHP, we can install the php5-mysql package. It's a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this:

aptitude search php5

Pick the ones you need and install them like this:

aptitude install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json

Now restart Apache2:

/etc/init.d/apache2 restart

Now reload in your browser and scroll down to the modules section again. You should now find lots of new modules there, including the MySQL module:


7 phpMyAdmin

phpMyAdmin is a web interface through which you can manage your MySQL databases. It's a good idea to install it:

aptitude install phpmyadmin

You will see the following questions:

Web server to reconfigure automatically: <-- apache2
Configure database for phpmyadmin with dbconfig-common? <-- No

Afterwards, you can access phpMyAdmin under


Share this page:

Suggested articles

30 Comment(s)

Add comment


By: Anonymous

"sudo su" is NEVER necessary, use "sudo -i" to setup the environment properly. Telling people to use "sudo su" is just bad practice.

By: jeremy

well i cant say much for this guy but i think it is grate what you guys are doing for the new linux guy that knows a lot on windows but trying to find his way to the lite

By: chenhaw

I suggest to add in FTP installation guide.

By: don

When I installed and started apache2 I got this message * Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName ... waiting apache2: Could not reliably determine the server's fully qualified domain name. Using for ServerName The rest of the installation went fine (substituting instead of until I installed phpmyadmin. Then when I browsed to I got a 404-not found message. I searched for phpmyadmin but could not locate it. For folk (read 'idiots') like me it might be a good idea to include some guidance on what to do when things don't work out the way they should :)

By: Proteus

This is one of the serious omissions in this article/tutorial. One should never leave the Apache directive ServerName at its default value. This default is useless. It should always be explicitly set to something useful.

It is a good idea, for example, to include the port in ServerName.

The name has to resolve, so unless you want to share only the IP address, it should be a name that will resolve under DNS.


By: Dasha Salo

To make PhpMyAdmin work try to configure apache2.conf to use PHPMyAdmin via browser:

$ sudo gedit /etc/apache2/apache2.conf

Then insert the line below into apache2.conf:

Include /etc/phpmyadmin/apache.conf


By: Anonymous

Maybe you also could add how to get ruby, ruby on rails to this.

By: Anonymous

Thanks for the great information.  This really made it simple to install :)

By: heiner

very nice summary. saves a lot of work. THANKS !!!!

By: Anonymous

thanks a lot..  very nice tutorial.

By: tarabo

Step 7.

sudo ln -s /usr/share/phpmyadmin/ /var/www

By: Deb

"sudo ln -s /usr/share/phpmyadmin/ /var/www "

That made my day!

I can not thank you enough! Excellent tutorial , brief and to-the-point !!

Best regards, 



By: Jemli Aymen

:-) thks

By: ejac

What if you already transfer the webroot to /user/public_html?
Anyway its still the same you just have to change its directory... :) Thanks for the contribution.. :)

By: Anonymous

Big help!!

By: JimmyK

If you want to install it all in one go, just use:

sudo tasksel install lamp-server

You'll have to do phpmyadmin yourself if you want it, but that command will set up all the rest for you.

By: Anonymous

Thank you very much))


Great tutorial, thank you very much.

By: Anonymous

Great tutorial, thanks !!

By: MrBadger

Yes, great tutorial.

Worked just as advertised.

 One note however. If you install PhpMyAdmin the default user name is "root" and the associated password. Took me a moment to figure out how to create a new user until I realized what it had defaulted to.

By: Shahzad

Great tutorial...

I couldn't move forward from the following step 

vi /var/www/info.php this command opens editor but do nothing and i have to exit from terminal

where to write the following code


aptitude search php5 this works fine gives a list of options

aptitude install php5-mysql php5-curl php5-gd php5-idn php-pear
php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming
php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy
php5-xmlrpc php5-xsl php5-json

/etc/init.d/apache2 restart  this command fails and displays the following information

 * Restarting web server apache2                                                apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName
apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName
(13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address
no listening sockets available, shutting down
Unable to open logs

aptitude install phpmyadmin this also fails and displays following msg

[email protected]:~$ aptitude install phpmyadmin
Reading package lists... Done
Building dependency tree      
Reading state information... Done
Reading extended state information     
Initializing package states... Done
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
[email protected]:~$

now please suggest me what to do


Thanks & Regards


By: chamala

Hey guys tx fr de was nice....

hi Shahzad,

if you are using vi editor, you have to use Esc+i (press Escape and i keys) to insert or enter values in a file. to save the file use Esc+wq!, Esc+q! for exit without modifications.


i hope this helps u....

have a nice day....


By: Anonymous

frist become a super userver

$sudo su

tell put the install commond

# aptitude install phpmyadmin

By: Anonymous

this is an amazing tutorial. been trying to get this stuff setup on mac and scratching my head. such a quick setup process on ubuntu.

By: Anonymous

HI, this artical is great.... i used this ... its very easy to learn... thanks for this ..............



By: Anonymous

Thank you for the simple and clear walk-through--it was very easy and is very much appreciated!

By: Rich

Minor gripe:

I can't escape the feeling you should have added one more step to your GREAT tutorial -- I logged into phpMyAdmin and it seems you me you might have included some advice about what to do with this page.




By: RonanOD

Great Howto! Thanks a million...

By: Anonymous

Thanks. I did everything you showed except for the MySQL (I would like to use Oracle). I was trying to place the same php test file under a webapps directory without success. It looks like if the webapp is set up for JSP, then I guess it does not know about php.

Thanks again,  Mark L.



By: Travel and Tourism Courses Brisbane

This is good, I'll be applying this to my system and see if it really work and helps. This look so helpful and convenient to use.