贊助商連結

Lighttpd 透過 FastCGI 跑 PHP

作業環境:

1.安裝 php5

1
2
[root@sun ~]#cd /usr/ports/lang/php5/
[root@sun php5]#make install clean

2.Options for php5 5.2.1_3

選擇要開啟的支援

1
2
3
4
5
6
[X] CLI Build CLI version
[X] CGI Build CGI version
[X] SUHOSIN Enable Suhosin protection system
[X] IPV6 Enable ipv6 support
[X] FASTCGI Enable fastcgi support (CGI only)
[X] PATHINFO Enable path-info-check support (CGI only)

3.編輯 lighttpd.conf

將 "mod_fastcgi" 註解移除

1
2
3
4
# "mod_setenv",
"mod_fastcgi",
# "mod_proxy",
# "mod_simple_vhost",

將 fastcgi 區塊的註解移除

1
2
3
4
5
6
7
8
9
## for PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fastcgi.socket",
"bin-path" => "/usr/local/bin/php-cgi"
)
)
)

4.編輯 php.ini

1
將 cgi.fix_pathinfo = 1 加入 

5.重新啟動 lighttpd

1
[root@sun ~]#/usr/local/etc/rc.d/lighttpd restart

參考連結

http://trac.lighttpd.net/trac/wiki/Docs%3AModFastCGI