Skip to main content

lighttpd

Posted in

Installing PHP with the lighttpd web server.

Compiling and Installing
At a minimum, for installing the lighttpd, PHP needs to be configured with these options:

./configure \
--enable-mbstring \
--with-gd \
--with-gettext

The --with-apxs2 and --with-apxs configuration options are not required. Add any other PHP options that you need.
MySQL, add:
--with-mysql=/usr/local/mysql

If you want to include LDAP support, add:
--with-ldap

If it configures correctly, make and install the binaries:
make
make install

Copy the included .ini file to the proper location:
cp php.ini-production /usr/local/lib/php.ini

Edit /usr/local/lib/php.ini and add:
cgi.fix_pathinfo = 1

Make sure mod_fastcgi is loaded in your /service/lighttpd/root/lighttpd.conf:
server.modules = (
  "mod_fastcgi",
)

Then add this basic section to the same file:
fastcgi.server = ( ".php" => ((
   "bin-path" => "/usr/local/bin/php-cgi",
   "socket" => "/tmp/php.socket"
)))

Add index.php to the index-file.names in your /service/lighttpd/root/lighttpd.conf so it looks something like:
index-file.names = ( "index.html", "index.php" )

Restart the lighttpd server. Since we are running it under daemontools:

svc -t /service/lighttpd