yp1234 发表于 2015-8-3 09:40:55

FreeBSD Configure Apache 2.2 PHP with FastCGI mod_fcgi Module

  http://www.bsdlover.cn/html/86/t-786.html
  
FreeBSD Configure Apache 2.2 PHP with FastCGI mod_fcgi Module
剑心通明 发表于: 2008-4-07 16:29 来源: BSD爱好者乐园


Q. I'd like to switch from mod_php5 to mod_fastcgi. I'm using FreeBSD 7 release along with following software:

+ Apache 2.2
+ PHP as mod_php5
+ MySQL DB 5.1.23 server
How do I configure php as FastCGI server?


A. mod_fcgid has a newprocess management strategy, which concentrates on reducing the numberof fastcgi server, and kick out the corrupt fastcgi server as soon aspossible. It is a binary compatibility alternative to Apache module mod_fastcgi;so your existing fastcgi programs do not need to be recompiled. mod_fcgid supports suEXEC.
Why run PHP5 as mod_fcgi / mod_fastcgi?FastCGI as has some serious advantages over mod_php5:

[*]You can do user level separations. You can enable quotas per user. Limit users by processes and CPU consumption.
[*]chroot security call per user possible
[*]According to several reports fastcgi works much faster than mod_php and cgi mode.
Step # 1: Install mod_fcgidMake sure your ports are upto date:
# portsanp fetch update
Install mod_fcgid:
# make install clean
Make sure php supports FastCGIMake sure php-cgi binary exists and it is compiled with fastcgi support:
# cd /usr/ports/lang/php5
# make showconfig | grep -i FASTCGI

Output:
FASTCGI=on "Enable fastcgi support (CGI only)"Another way to test fastcgi support, enter:
# /usr/local/bin/php-cgi -v
Output:
/usr/local/bin/php-cgi -v
PHP 5.2.5 with Suhosin-Patch 0.9.6.2 (cgi-fcgi) (built: Mar6 2008 09:15:41)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
If you don't see word cgi-fcgi, recompile php with fastcgi support by visiting /usr/ports/lang/php5
# cd /usr/ports/lang/php5
# make config
# make install clean
Step # 3: Load mod_fcgi moduleOpen your httpd.conf file located at /usr/local/etc/apache22/ directory:
# vi /usr/local/etc/apache22/httpd.conf
Load mod_fcgi module:
LoadModule fcgid_module libexec/apache22/mod_fcgid.so
Configure mod_fcgi

    AddHandler fcgid-script .fcgi
    FCGIWrapper /usr/local/bin/php-cgi .php
Find your DocumentRoot directory configuration option that read as follows:
Append following two lines:
SetHandler fcgid-script
FCGIWrapper /usr/local/bin/php-cgi .php
Options ExecCGI

At the end configuration should read as follows:
# This should be changed to whatever you set DocumentRoot to.

    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    SetHandler fcgid-script
    FCGIWrapper /usr/local/bin/php-cgi .php
    Options ExecCGI
Allow from all
Step # 4: Disable mod_php5Find line that read as follows:
LoadModule php5_module      libexec/apache22/libphp5.so
Comment out line:
#LoadModule php5_module      libexec/apache22/libphp5.so
Also make sure following two line (mime type) exists:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Save and close the file.
Step # 5: Restart Apache22Finally, restart apache web server:
# /usr/local/etc/rc.d/apache22 restart
Step # 5: Test mod_fcgiUse following small program to verify mod_fcgi is working properly:
You must see Server API as CGI/FastCGI as well as following screen:
http://bbs.bsdlover.cn/attachments/month_0804/20080407_c64e61b02cc05ec82f32JbmYXPfOnUWi.png
freebsd-php5-cgi-fcgi-mod-fcgi.png

(Fig. 01: PHP5 Configured as FastCGI using mod_fcgi)
最新回复
kof2002 at 2008-5-10 16:10:24
事前安装了FAMP
按照上述的方法作了 但是运行apache出现下面的httpd。conf语法错误提示 说不是一个版本的apache 模块?? 然后我从新更新了apache编译安装 还是不行
请问该怎么办呢?http://bbs.bsdlover.cn/images/smilies/default/sweat.gif http://bbs.bsdlover.cn/images/smilies/default/cry.gif

[ 本帖最后由 kof2002 于 2008-5-10 16:11 编辑 ]
http://bbs.bsdlover.cn/attachments/month_0805/20080510_ad99583dc5715aab9a06yFDtzDDUqci8.jpg
screenshot.jpg
剑心通明 at 2008-5-10 16:34:14
把apache相关的都给deinstall了,把ports更新一下再装试试kof2002 at 2008-5-12 16:05:14
重新卸载安装了 终于搞定了 谢谢 剑心通明了http://bbs.bsdlover.cn/images/smilies/default/lol.gif http://bbs.bsdlover.cn/images/smilies/default/handshake.gif
不知道cgi-fcgi的兼容性如何 语法限制更严格吧?

cgi-fcgiDirectiveLocal ValueMaster Valuecgi.check_shebang_line11cgi.fix_pathinfo11cgi.force_redirect11cgi.nph00cgi.redirect_status_envno valueno valuecgi.rfc2616_headers00fastcgi.logging11
页: [1]
查看完整版本: FreeBSD Configure Apache 2.2 PHP with FastCGI mod_fcgi Module