Introduction

Lighttpd, sometimes pronounced "Lighty", is a secure, fast, compliant, and very flexible web-server that has been optimized for high-performance environments. In this guide we'll cover configuring Lighttpd to use FastCGI to serve PHP scripts.

Installation

Install the lighttpd from the Universe repository.

You'll also need:

  • php5
  • php5-cgi

Configuration

The lighttpd.conf configuration file uses BNF like notation which is quite different from Apache's directive configuration style. If you're familiar with configuring web servers most of lighttpd's configuration won't come as a surprise however.

Fortunately the lighttpd package comes with a configuration file for FastCGi it just needs to be enabled.

  • To enable FastCGI open a console and enter:

sudo lighty-enable-mod

at the prompt type fastcgi and press <ENTER>

This will create a symlink to /etc/lighttpd/conf-available/10-fastcgi.conf in /etc/lighttpd/conf-enabled

  • Once the FastCGI configuration has been enabled lighttpd needs to be reloaded:

sudo /etc/init.d/lighttpd force-reload

If all went well Lighttpd should now be able to serve PHP files.

Test PHP

To test that Lighttpd is indeed serving PHP files we'll create the common info.php to list PHP's configuration.

  • In your favorite text editor create a new file named info.php and enter:

<?php

phpinfo();

?>
  • Next copy the file into your server.document-root.

    • This is /var/www by default.

sudo cp info.php /var/www
  • Finally point your favorite browser to http://localhost/info.php and you should see information regarding your PHP environment.

  • After you've confirmed that Lighttpd is serving PHP files it's a good idea to remove the info.php file for security reasons.

Note: this guide has been tested on Ubuntu 7.04 (Feisty) and Ubuntu 7.10 (Gutsy).


PhpLighttpd (last edited 2009-04-30 03:41:14 by adsl190-027000006)