First use php-cgi-v to see if PHP supports fastcgi. The output on my machine is as follows:
PHP 5.2.4-2ubuntu5.1 with Suhosin-patch 0.9.6.2 (cgi-fcgi) (Built:may 9 2008 16:26:18)
Copyright (c) 1997-2007 the PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technol
Then find the location of php-cgi:
Which php-cgi
Output:/usr/bin/php-cgi
For the newer version of the LIGHTTPD, the configuration file made a more reasonable processing, many online tutorials said to modify the/etc/lighttpd/lighttpd.conf. If you are installing a newer version, you have a 10-fastcgi.conf file under/etc/lighttpd/conf-avalible.
First back up:
sudo cp 10-fastcgi.conf bak.10-fastcgi.conf
Then open:
sudo vim 10-fastcgi.conf
The simplest configuration for adding or modifying content is as follows:
Fastcgi.server= (
". php" = (
"Bin-path" = "/usr/bin/php-cgi" #上文中which location found php-cgi
"Socket" = "Tmp/php.socket"
))
)
Of course, you can also configure a lot of other content such as Max-proces/idle-timeout. Restart LIGHTTPD after configuration is complete:
SUDO/ETC/INIT.D/LIGHTTPD restart
-----If you want to enable the. html to. PHP Mapping
It is important to note that the Mod_compress module must be closed first. The initial configuration in the lighttpd.conf file is:
Server.modules = (
"Mod_access",
"Mod_alias",
"Mod_accesslog",
"Mod_compress",
# "Mod_rewrite",
....
....
Compress.cache-dir = "/var/cache/lighttpd/compress/"
Compress.filetype = ("Text/plain", "text/html", "application/x-JavaScript", "Text/css")
....
....
Here are two options: either comment out the mod_compress, or cancel the compression of the. html file. Here to remove text/html from the Compress.filetype.
Then open 10-fastcgi.conf, add
Fastcgi.map-extensons= (". html" = ". php")