欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

Win7下通过FastCGI配置IIS7以执行php脚本

程序员文章站 2022-06-06 15:01:59
...

Name: PHP via FastCGI 3. Modify the Resuest Restrictions configuration: 4. Click OK . and 4. In the Add Module Mapping confirmation dialog box that asks if you want to create a FastCGI application for this executable, click Yes .\ 5. Test t

Name: PHP via FastCGI

Win7下通过FastCGI配置IIS7以执行php脚本

3. Modify the Resuest Restrictions configuration:

Win7下通过FastCGI配置IIS7以执行php脚本

4. Click OK. and 4. In the Add Module Mapping confirmation dialog box that asks if you want to create a FastCGI application for this executable, clickYes.\

Win7下通过FastCGI配置IIS7以执行php脚本

5. Test that the handler mapping works correctly by creating a phpinfo.php file in the C:\inetpub\wwwroot folder that contains the following code:

6. Open a browser and navigate to http://localhost/phpinfo.php. If everything was setup correctly, you will see the standard PHP information page.

在这一步中,为了更加方便地检测Php是否安装成功,可以在cmd中,cd到c:\php目录下执行:php-cgi.exe D:\phpTest\test.php来验证。

Win7下通过FastCGI配置IIS7以执行php脚本

NOTE: If you do not see FastCgiModule in theModules: list, the module is either not registered or not enabled. To check if the FastCGI module is registered, open the IIS configuration file that is located at %windir%\windows\system32\config\applicationHost.config and check that the following line is present in the div:

In the same file, also check that the FastCGI module is added to the div:

Configure IIS 7 to handle PHP requests by using the command line

Alternatively, you can complete the steps above by using the command line tool AppCmd.

1. Create the FastCGI application process pool by running the following command:

C:\>%windir%\system32\inetsrv\appcmd set config /div:system.webServer/fastCGI /+[fullPath='c:\{php_folder}\php-cgi.exe']

2. Create the handler mapping by running the following command:

C:\>%windir%\system32\inetsrv\appcmd set config /div:system.webServer/handlers /+[name='PHP_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='c:\{php_folder}\php-cgi.exe',resourceType='Unspecified']

Note: If you are using PHP version 4.X, you can use php.exe instead of php-cgi.exe.

BTW, 在这个过程中,可能会遇到500错误:

Error info:

HTTP Error 500.0 - Internal Server Error
C:\PHP\php-cgi.exe - The FastCGI process exited unexpectedly

Detailed Error Information

Module: FastCgiModule
Notification: ExecuteRequestHandler
Handler: PHP via FastCGI
Error Code: 0x000000ff
Requested URL: localhost/test.php
Physical Path: C:\inetpub\wwwroot\test.php
Logon Method: Negotiate
Logon User: Domain\user

引起这个问题的关键还是php.ini文件的设置有问题,可以通过排除法来解决:直接到 c:\php目录下,双击PHP-CGI.EXE, 在弹出的命令行窗口下看具体是什么错误,然后相应地修改php.ini文件,清除掉(用;注释掉)无效的或者提示找不到的extensions,就可以使用了。

Try to execute PHP-CGI.EXE (BY DOUBLECLICKING ON IT). See if you get any error messages/ pop-ups. I got a ton of them and it all boiled down on having a bunch of extensions turned on, but not being available in my ext folder. Clear the PHP.INI of those invalid extensions and the problem should go away.