FreeBSD 下讓 PHP 以 FastCGI interface 跟 http server 連結

真討厭,看了看 /usr/ports/lang/php5 的 Makefile,只有在 /usr/ports/www/php5-cgi 下面 compile 的才會有 FastCGI… (而且還要加上一些 option)

首先,先在 /usr/ports/www/php5-cgi 下面安裝 PHP with FastCGI…

cd /usr/ports/www/php5-cgi
make WITH_FASTCGI=yes install clean

然後輸入 php -v 應該可以看到 fastcgi support:

PHP 5.0.1 (cgi-fcgi) (built: Oct 10 2004 13:57:37)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.1, Copyright (c) 1998-2004 Zend Technologies

再來安裝 lighttpd,或是 apache

cd /usr/ports/www/lighttpd or /usr/ports/www/apache2
make install clean

如果跑 apache 的話需要再安裝 mod_fastcgi

cd /usr/ports/www/mod_fastcgi
make install clean

該裝的都裝完以後,把設定檔設一設,再把 php 跑起來 (用 -b 的參數) 就 ok 了。