Chinaunix首页 | 论坛 | 博客
  • 博客访问: 443741
  • 博文数量: 95
  • 博客积分: 7012
  • 博客等级: 少将
  • 技术积分: 1127
  • 用 户 组: 普通用户
  • 注册时间: 2008-05-13 22:49
文章存档

2010年(5)

2009年(43)

2008年(47)

我的朋友

分类: WINDOWS

2008-10-14 11:41:10


                  在 IIS6 配置使用php的fastcgi模式

1、下载并安装FastCGI Extension for Internet Information Services 6.0
 
2、下载php-5.2.6-Win32.zip
解压到D:\php目录下
设置IIS启动帐号对D:\php\有读取执行权限
3、注册PHP到FastCGI
cscript fcgiconfig.js -add -section:"php" -extension:php -path:"D:\php\php-cgi.exe"
4、做一些性能和安全设置
D:\php\php.ini-recommended重命名为为D:\php\php.ini
打开D:\php\php.ini,修改:
extension_dir = "D:\php\ext"
fastcgi.impersonate = 1
cgi.fix_pathinfo=1
cgi.force_redirect = 0
php.ini 其他的地方设置跟平时配置isapi 模式一样;
执行:
cscript fcgiconfig.js -set -section:"PHP" -InstanceMaxRequests:10000
cscript fcgiconfig.js -set -section:"PHP" -EnvironmentVars:PHP_FCGI_MAX_REQUESTS:10000
以上两项设置最大池和响应连接数,可以根据自己的硬件配置、使用情况修改
 
这时打开才C:\windows\system32\inetsrv\fcgiext.ini 内容如下:
[Types]
php=php
[php]
ExePath=D:\php\php-cgi.exe
InstanceMaxRequests=10000
EnvironmentVars=PHP_FCGI_MAX_REQUESTS:10000
 
以下是官方的配置文档:
  Configuring FastCGI Extension to Work with PHP
Once PHP is installed on Windows, you have two options for configuring FastCGI: use the
configuration script provided with the installation of the FastCGI extension, or perform all
the configuration tasks manually by modifying IIS configuration settings and fcgiext.ini
file. Depending on the option, refer to the corresponding sections below.
Using Script for Configuring FastCGI Extension to Work with PHP
The configuration script with the name fcgconfig.js is provided with the installation of
FastCGI extension and is located in %WINDIR%\system32\inetsrv. To configure FastCGI extension
to work with PHP, follow the steps below:
Open a command line window, change the current directory to %WINDIR%\system32\inetsrv, and
run the configuration script to register the PHP CGI program as the one that will be
processing .php extensions:
cscript fcgiconfig.js -add -section:"PHP" -extension:php -path:"C:\PHP\php-cgi.exe"(replace
C:\PHP\php-cgi.exe with the path to php-cgi.exe if you installed to a directory other than
C:\PHP)
Note: If you do not want to register the PHP extension to be processed by the FastCGI
component on your entire server, and only want to register it for a specific web site, then
add a "–site:[siteId]" argument, e.g:
cscript fcgiconfig.js -add -section:"PHP" -extension:php -path:"C:\PHP\php-cgi.exe" –
site:1Note: For a complete list of configuration parameters supported by FastCGI extension,
refer to the FastCGI extension documentation.

Full PHP functionality support and performance of PHP applications running on the FastCGI
extension were the main goals and focus for the IIS team. During our internal testing and in
collaboration with Zend Technologies, we identified the set of configuration settings for the
FastCGI extension and PHP that provide optimal functionality and performance for PHP
applications when running on Windows via the FastCGI extension.
Configure your server as described below:
    1.  Modify the php.ini file as follows:
Set fastcgi.impersonate = 1. FastCGI under IIS supports the ability to impersonate the
security tokens of the calling client. This allows IIS to define the security context under
which the request runs.
Set cgi.fix_pathinfo=1. cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support
for CGI. PHP's previous behavior was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not
care what PATH_INFO is. For more information on PATH_INFO, see the cgi specifications.
Setting this to 1 causes PHP CGI to fix its paths to conform to the specification.
Set cgi.force_redirect = 0.
    2.  Set the FastCGI configuration settings for the PHP section by running fcgiconfig.js
as follows:
Set the FastCGI process pool property InstanceMaxRequests to 10000. This setting specifies
that the FastCGI extension will recycle php-cgi.exe after it has processed 10000 requests
successfully.
> cscript fcgiconfig.js -set -section:"PHP" -InstanceMaxRequests:10000    3.  Configure the
FastCGI extension to set PHP_FCGI_MAX_REQUESTS environment variables for the PHP process to
10000.This setting instructs php-cgi.exe to recycle itself after it has processed 10000
requests successfully.

> cscript fcgiconfig.js -set -section:"PHP" -EnvironmentVars:PHP_FCGI_MAX_REQUESTS:10000
Note: You can configure InstanceMaxRequests and PHP_FCGI_MAX_REQUESTS to use numbers other
than 10000. As a general rule, always make sure that the value of InstanceMaxRequests is less
than or equal to the value of PHP_FCGI_MAX_REQUESTS.
 
阅读(2692) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~