Lighttpd 透過 FastCGI 跑 PHP
作業環境:
- FreeBSD 6.1-RELEASE
- Lighttpd 1.4.13
- PHP 5.2.1
1.安裝 php5
[root@sun ~]#cd /usr/ports/lang/php5/
[root@sun php5]#make install clean
2.Options for php5 5.2.1_3
選擇要開啟的支援
[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" 註解移除
# "mod_setenv",
"mod_fastcgi",
# "mod_proxy",
# "mod_simple_vhost",
將 fastcgi 區塊的註解移除
## 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
將 cgi.fix_pathinfo = 1 加入
5.重新啟動 lighttpd
[root@sun ~]#/usr/local/etc/rc.d/lighttpd restart