We will see how to let lighttpd execute PHP scripts and display their results instead of their content.
FastCGI configuration of PHP5
To execute PHP scripts, lighttpd can use the standardised interface CGI that is used by web servers. It is an interface that allow easily the exchange between a web server and a rending engine. Two version of this interface are available in lighttpd, the classic one (CGI) and rapid one (FastCGI). We will use that latest in our configuration.
We will start by installing the CGI version of PHP5
# aptitude install php5-cgi
The configuration take place in the
/etc/lighttpd/conf-available/10-fastcgi.conf file. It should look like
server.modules += ( "mod_fastcgi" ) fastcgi.server = ( ".php" => (( "bin-path" => "/usr/bin/php-cgi", "socket" => "/tmp/php.socket" )))
The first line activate FastCGI. The rest associates the file that have
.php extension to PHP and render them using the CGI version of PHP5.
To activate the configuration you only need to create a symbolic link of that
# ln -s /etc/lighttpd/conf-available/10-fastcgi.conf /etc/lighttpd/conf-enabled/
A restart of lighttpd is then necessary to take the new configuration into account:
# service lighttpd restart