2011年11月18日 星期五

PHP on IIS 7.0 using FastCGI

Step1 . Install FastCGI

1.In the Windows Start Menu choose "Run:", type "CompMgmtLauncher" and click "Ok";

2.If the "Web Server (IIS)" role is not present under the "Roles" node, then add it by clicking "Add Roles";

3.If the "Web Server (IIS)" role is not present under the "Roles" node, then add it by clicking "Add Roles";

4.Click "Next" and then "Install" and wait for the installation to complete.

Step2 .PHP Install

1.Go to http://tw.php.net/downloads.php Download PHP

2.Select Windows Binaries

3.PHP5.3 VC9X86 Non Thread Safe-Zip

4.Unpack the files to the directory of your choice (e.g. C:\PHP). Rename the php.ini-production file to php.ini.

5.Open the php.ini file. Uncomment and modify the settings as follows:

;cgi.force_redirect = 1 改成 cgi.force_redirect = 0
;cgi.fix_pathinfo=1 改成 cgi.fix_pathinfo=1
;extension_dir = "ext" 改成 extension_dir = "ext"
;fastcgi.impersonate = 1; 改成 fastcgi.impersonate = 1
;extension=php_mbstring.dll 改成 extension=php_mbstring.dll
;extension=php_mysql.dll 改成 extension=php_mysql.dll
extension=php_mysql.dllshort_open_tag= 改成 short_open_tag= On

6.Save php.ini.
7.Open an Command
c:\php\php -info
Step3.Setting IIS
1.In the Windows Start Menu choose "Run:", type "inetmgr" and click "Ok";
2.In the IIS Manager user interface select the server node in the "Connections" tree view;
3.In the "Features View" page open the "Handler Mappings" feature;
4.In the "Actions" pane click "Add Module Mapping...";
5.In the "Add Module Mapping" dialog enter the following:
Request path: *.php
Module: FastCgiModule
Executable: C:\[Path to PHP installation]\php-cgi.exe
Name: PHP_via_FastCGI
6.Click "Request Restrictions" button and then configure the mapping to invoke handler only if request is mapped to a file or a folder;
7.Click OK on all the dialogs to save the configuration.
Step4.Testing PHP
1.creating a phpinfo.php file in the C:\inetpub\wwwroot folder that contains the following code:

<?php

phpinfo();

?>

 
Scenario 1

Error Message:

HTTP Error 500.0 - Internal Server

ErrorError Code: 0x00000000

Solution:

1.check correct syntax
2.<?php…?> is write <?…?> . please open php.ini modify short_open_tag = On.
Scenario 2

Solution:

1.can open php.ini modify
 error_reporting = E_ALL   &  display_errors = On