Lighttpd 透過 FastCGI 跑 PHP
作業環境:
- FreeBSD 6.1-RELEASE
- Lighttpd 1.4.13 (opens new window)
- PHP 5.2.1
1.安裝 php5
{% codeblock lang:bash %} [root@sun ~]#cd /usr/ports/lang/php5/ [root@sun php5]#make install clean {% endcodeblock %}
2.Options for php5 5.2.1_3
選擇要開啟的支援
{% codeblock lang:bash %} [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) {% endcodeblock %}
3.編輯 lighttpd.conf
將 "mod_fastcgi" 註解移除
{% codeblock lang:bash %}
# "mod_setenv",
"mod_fastcgi",
# "mod_proxy",
# "mod_simple_vhost",
{% endcodeblock %}
將 fastcgi 區塊的註解移除
{% codeblock lang:bash %}
# 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" ) ) ) {% endcodeblock %}
4.編輯 php.ini
{% codeblock lang:bash %} 將 cgi.fix_pathinfo = 1 加入 {% endcodeblock %}
5.重新啟動 lighttpd
{% codeblock lang:bash %} [root@sun ~]#/usr/local/etc/rc.d/lighttpd restart {% endcodeblock %}
# 參考連結
http://trac.lighttpd.net/trac/wiki/Docs%3AModFastCGI (opens new window)