Installing Lighttpd With PHP5 And MySQL Support On Ubuntu 11.04

Version 1.0
Author: Falko Timme
Follow me on Twitter
Last edited 05/12/2011

Lighttpd is a secure, fast, standards-compliant web server designed for speed-critical environments. This tutorial shows how you can install Lighttpd on an Ubuntu 11.04 server with PHP5 support (through FastCGI) 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:

apt-get 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 root@localhost as well as, 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 Lighttpd

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

apt-get install lighttpd

Now direct your browser to, and you should see the Lighttpd placeholder page:

Lighttpd's default document root is /var/www on Ubuntu, and the configuration file is /etc/lighttpd/lighttpd.conf. Additional configurations are stored in files in the /etc/lighttpd/conf-available directory - these configurations can be enabled with the lighttpd-enable-mod command which creates a symlink from the /etc/lighttpd/conf-enabled directory to the appropriate configuration file in /etc/lighttpd/conf-available. You can disable configurations with the lighttpd-disable-mod command.


4 Installing PHP5

We can make PHP5 work in Lighttpd through FastCGI. Fortunately, Ubuntu provides a FastCGI-enabled PHP5 package which we install like this:

apt-get install php5-cgi

Share this page:

2 Comment(s)

Add comment


From: Asgher Hussain Qambrani at: 2013-10-22 07:32:50

it's really nice to share with us... simple steps, no complications, so many thanks to you.

From: WWW at: 2011-06-28 12:07:43

Since the article seems to be for relative newbies, I'd recommend that anyone following this avoid the fastcgi install, until you read up on the configuration options and understand them. Someone with minimal knowledge could follow the instructions here and the basic setup would work fine, but fastcgi can cause problems without proper configuration. Not understanding and setting the cache properties correctly for your system and intended use will most likely result in worse performance and possibly errors and failure to serve pages. Most importantly, it's just not something that is useful for a basic setup and the target audience here seems to be beginners. Beginners should concentrate on learning the basic lighttpd and php configuration options before moving on to fastcgi.