Rabu, 24 September 2008

how to enable php5 fastcgi in lighttpd webserver

php5 fastcgi on lighttpd server.
from linux distro,
1. install lighttpd
2. install php5

open gnome-terminal or kkonsole
type su - root
enter the root password

- go to /etc/lighttpd folder, type: cd /etc/lighttpd (press enter)

- edit modules.conf,
- uncomments the lines: #include "conf.d/fastcgi.conf" by removing the # character.
- edit the fastcgi.conf by typing: vi conf.d/fastcgi.conf
- uncomments the lines from:
#fastcgi.server = ( ".php" =>
....
# )
##
## Ruby on Rails Example

i.e:

fastcgi.server = ( ".php" =>
( "php-local" =>
(
"socket" => socket_dir + "/php-fastcgi-1.socket",
"bin-path" => server_root + "/cgi-bin/php5",
"max-procs" => 1,
"broken-scriptfilename" => "enable",
)
),
( "php-tcp" =>
(
"host" => "127.0.0.1",
"port" => 9999,
"check-local" => "disable",
"broken-scriptfilename" => "enable",
)
),

( "php-num-procs" =>
(
"socket" => socket_dir + "/php-fastcgi-2.socket",
"bin-path" => server_root + "/cgi-bin/php5",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "16",
"PHP_FCGI_MAX_REQUESTS" => "10000",
),
"max-procs" => 5,
"broken-scriptfilename" => "enable",
)
),
)

- adjust the php fastcgi information in php.ini.
vi /etc/php5/fastcgi/php.ini
find the line :
#cgi.fix_pathinfo=1
uncomment the line.
- last thing is:
ensure the lighttpd user can access to sessions folder, path and modules.
i.e, by default the php session located in /var/lib/php5 folder,
then, you can change the default php folder or give lighttpd permission to the folder by using this command:
chown -vR lighttpd:root /var/lib/php5


Done. now, you have the fastcgi webserver powered by lighttpd and php as cgi (fastcgi).