基本上利用 FreeBSD 的 ports 安裝就可以了:
1. 先安裝 apache with MPM = worker
cd /usr/ports/www/apache22
make WITH_MPM=worker install clean
pkg_info | grep apache
#
# 會出現
#
apache-worker-2.2.9_5 Version 2.2.x of Apache web server with worker MPM.
2. 安裝 PHP5 跟 PHP5-extensions
cd /usr/ports/lang/php5; make install clean
cd /usr/ports/lang/php5-extensions; make install clean
3. 安裝 mod_fastcgi
cd /usr/ports/www/mod_fastcgi
make install clean
全部安裝完成,先修改 httpd.conf
#
# 把下面這行 umark 掉
#
# Server-pool management (MPM specific)
Include etc/apache22/extra/httpd-mpm.conf
修改 Include etc/apache22/extra/httpd-mpm.conf
mpm_worker_module 那段:
ThreadLimit 512
StartServers 1
MaxClients 512
MinSpareThreads 1
MaxSpareThreads 512
ThreadsPerChild 512
MaxRequestsPerChild 0
這樣 MPM worker 就設定完成了,接下來設定 mod_fastcgi
到 /usr/local/etc/apache22/httpd.conf 把底下這一段的註解拿掉
LoadModule fastcgi_module libexec/apache22/mod_fastcgi.so
新增設定檔:/usr/local/etc/apache22/Includes/fastcgi.conf,內容如下:
#
FastCgiConfig -maxClassProcesses 1
ScriptAlias /fcgi-bin/ "/usr/local/www/fcgi-bin/"
<Directory /usr/local/www/fcgi-bin/>
SetHandler fastcgi-script
AllowOverride All
Order allow,deny
Allow from all
Directory>
#
AddHandler php-fastcgi .php
Action php-fastcgi /fcgi-bin/php
這裡設定只能跑一隻 配合前面的 MPM worker,這樣確保所有的 apache 只會透過這個 fastcgi socket 跑 php。
然後再建立: /usr/local/www/fcgi-bin 這個資料夾,裡面擺入執行檔 php 內容是:
#!/bin/sh
PHPRC="/usr/local/etc"
export PHPRC
PHP_FCGI_CHILDREN=128
export PHP_FCGI_CHILDREN
exec /usr/local/bin/php-cgi
阅读(806) | 评论(0) | 转发(0) |