Lighttpd is a secure web server, which is faster when compared to Apache. We will show here how you can install Lighttpd on an Ubuntu 9.10 server with PHP5 support (through FastCGI) and MySQL support.

In this tutorial we have used hostname as with the IP address They maybe different for you.

The first thing you need to do is to login as root. You can login as root in Ubuntu Linux by typing in the terminal:

sudo su

Installing MySQL 5:

In the terminal type:

aptitude install mysql-server mysql-client

You will be asked to provide a password for MySQL user “root“. The same password will be valid for the user root@localhost as well as .

Installing Lighttpd on Ubuntu 9.10:

Lighttpd is already available as a pre-configured package in Ubuntu 9.10, so we can install it through terminal very easily. Type in the terminal:

aptitude install lighttpd

Now open your web browser and type, and you should see the Lighttpd placeholder page:


The default document folder of Lighttpd for user root is /var/www/ on Ubuntu, and the configuration file is /etc/lighttpd/lighttpd.conf. Additional configurations are stored in files which are situated in the /etc/lighttpd/conf-available/ directory.

Installing PHP5

To enable PHP5 in Lighttpd, you will have to  modify the configuration file /etc/php5/cgi/php.ini. To edit it, type in the terminal:

vi /etc/php5/cgi/php.ini

Scroll down to the end of this file and add this line at the end of file:

cgi.fix_pathinfo = 1

To enable the FastCGI configuration (which is stored in /etc/lighttpd/conf-available/10-fastcgi.conf), run the following command:

lighttpd-enable-mod fastcgi

To reload the server for changes to take place, type in the terminal:

/etc/init.d/lighttpd force-reload

Installing MySQL 5 support:

To get MySQL support in PHP, we can install the php5-mysql package. But it is a good idea to install some other PHP5 modules together with MySQL as well, as you might need them for your applications. You can search for available PHP5 modules by typing in the terminal:

aptitude search php5

Based on some of the packages that you select, you can install them with MySQL by typing in the terminal:

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, again restart Lighttpd by typing:

/etc/init.d/lighttpd restart

Testing your web server and PHP:

The document root for the default web server 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.

To create this file, type in the terminal:

vi /var/www/info.php

Now type this code into this file:


Save the file and close the terminal.

Now we call this file in a browser by typing


As you see in the screenshot, PHP5 is working fine, and it is working through FastCGI, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP5.Now, your web server is ready for working.

Hope this tutorial helps you in setting up a light and fast as well as a faster web server in Ubuntu 9.10. For more such tutorials, keep hooked onto TechPP.

Also Read:

Anurag Upadhaya is a Linux enthusiast, Counter Strike gamer, Tech blogger, Web designer and 24x7 netizen from Bangalore. Follow him on Twitter: @e_anurag | Drop him a line: anuragupadhaya[at]gmail[dot]com


4 thoughts on “How to Install Lighttpd with PHP5 and MySQL on Ubuntu 9.10

  1. I’ve searched the web for just this set of instructions for what seems forever. I can get this to work on a Windows Server 2008 and on Linux, but had a terrible time getting it to run on Windows 7 Ultimate. I followed these instructions to the letter (it was easy) and got the perfect results the very first time.
    Thanks! I really mean it! I had to have this for a very important project I am working on. This saved me!

Leave a Reply

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