Install Lighttpd, PHP and MySQL on Ubuntu 10.10

Post to Twitter

Sometimes you don’t want Apache for your web server whatever your reasons might be. There are other options like Nginx and Lighttpd, today I’ll setup Lighttpd along with PHP (via FastCGI) and MySQL.

Assuming you have a clean Ubuntu 10.10 system running go into the terminal and issue the following commands to install aptitude and Lighttpd:

$ sudo apt-get update
$ sudo apt-get install aptitude
$ sudo aptitude install lighttpd

Verify that Lighttpd is running: http://localhost/ You should see a default placeholder webpage.

Installing MySQL:

$ sudo aptitude install mysql-server mysql-client

Note: During the MySQL installation you will be prompted to set the root password.

Installing PHP (and some commonly used libraries – modify as needed):

$ sudo aptitude install php5-cgi php5-dev php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ps php5-pspell php5-recode php5-snmp php5-tidy php5-xmlrpc php5-xsl php5-common php5-mysql

In order to get Lighttpd and PHP working together you need to modify this file: /etc/php5/cgi/php.ini

$ sudo pico /etc/php5/cgi/php.ini

Inside the file look for the following line:


Change it to this:


Save and exit the file.

Finally here are the last few commands to enable the PHP configuration and FastCGI module as well as reloading the Lighttpd web server:

$ sudo lighty-enable-mod fastcgi
$ sudo lighty-enable-mod fastcgi-php
$ sudo service lighttpd force-reload

We can test out PHP with a simple script (see below). However, there are a few things to note first:
1. The Lighttpd default document root (On Ubuntu 10.10) is located at: /var/www
2. The lighttpd.conf file (On Ubuntu 10.10) is located at: /etc/lighttpd/lighttpd.conf

Create a new file called info.php in the /var/www folder:

sudo pico /var/www/info.php

Add this code to the new file and then save and exit.


Browse to http://localhost/info.php to examine all the PHP info.

Make sure MySQL is listed in there somewhere and you should be good to go.

Post to Twitter

This entry was posted in Open Source, PHP, Ubuntu. Bookmark the permalink.

7 Responses to Install Lighttpd, PHP and MySQL on Ubuntu 10.10

  1. Pingback: Install Lighttpd, PHP and MySQL on Ubuntu 10.10

  2. Joseph Scott says:

    If you are going to use fastcgi then I highly recommend using PHP-FPM

  3. Pingback: A quick and simple tutorial on how to use cURL with PHP

  4. Max says:


    When installing the PHP libraries, you inlcuded, “libapache2-mod-php5”. I assume thats not needed since we’re using lighttpd, correct?

    I read a lot about nginx & lighttpd, but haven’t had a need for them just yet.

    Thanks for sharing, I’ll be setting this up in some virtual sessions for testing.

  5. Chad Lung says:


    Your correct, thanks. Good catch.


  6. Is possible publish an article about :

    Config 1 = Lighttpd fastcgi thin rails3
    Config 2 = Nginx fastcgi thin rails3

    Thin is substitute for Mongrel (more faster and stable) Ruby could be REE 1.8.7 (low consume of memory)

    alternating Frontend/Backend ex. using the config 1 Frontend and config 2 Backend
    Now Config 1 is the Backend and the Config 2 is the Frontend.

    And please comment your impressions about the performance, I believe the combination of Lighttpd and Nginx is totally Killer, associated with Thin and with the coverage of Fastcgi and or memcached (or suggest Varnish Cache) to deploy rails applications is very very interesting.

  7. Chad Lung says:


    That won’t be a topic I’ll be doing any time soon, I’ve been moving away from Rails recently so I haven’t been keeping up with the latest trends on getting it setup and optimized.


Comments are closed.