windows2003下 apache 以fastcgi模式运行php 详解

来源:互联网 发布:淘宝一航日本笔假货 编辑:程序博客网 时间:2024/06/15 05:09

这两天一直在研究 apache以fastcgi模式运行php,发现很多网上说的都不够详细和具体,后台到国外网站找了一些资料,才了解到fastcgi 是个人开发出来的,当初是适应apache1.X版本,后台经过大牛们的一些优化终于开发出适合apache2.X版本名字叫做fcgid(其实跟fastcgi一样)。以下是安装配置流程:

1、先下载mod_fcgid.so(下载地址:http://www.apachelounge.com/download/),将mod_fcgid.so 放置apache安装目录的modules文件夹下。

2、在apache的http.conf文件里面添加

LoadModule fcgid_module modules/mod_fcgid.so

AddHandler fcgid-script .fcgi .php

#Set PHP_FCGI_MAX_REQUESTS to greater than or equal to FcgidMaxRequestsPerProcess

FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000

FcgidMaxRequestsPerProcess 1000

#Maximum number of PHP processes
FcgidMaxProcesses 15

FcgidIOTimeout  120

FcgidIdleTimeout  120
AddType application/x-httpd-php .php
参数可根据实际情况设置

3、虚拟主机配置加入相关配置如下

<VirtualHost 192.168.0.225:81>

#php安装路径
FcgidInitialEnv PHPRC "D:/webserver/php/"

#php-cgi.exe路径
FcgidWrapper "D:/webserver/php/php-cgi.exe" .php
ServerName 192.168.0.225:81
DocumentRoot "E:/www"
</VirtualHost>
<Directory "E:/www">
    Options Indexes  FollowSymLinks Includes ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

上面 “ExecCGI” 这个是必填,大家不要丢掉了。

4、这里定义了默认对网站根的访问权限。
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

这里需要改成改成
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

该步骤一般很多人都忘记加,因此就会出现 “You don't have permission to access /index.php on this server.” 这样的错误。

 

好了,所有的配置更改全部完成,重启apache,这个时候你会发现任务管理器里有php-cgi.exe的进程,我大概观察了一下,一般一个进程所耗费的内存是15mb的样子,所以FcgidMaxProcesses 这个参数可以根据服务器内存的大小来进行调整。