So as early as IIS 7.0 just appeared, Microsoft has provided a more optimized way to run PHP on IIS-FastCGI. But until IIS 7.5 appears with Windows 7, there are also a lot of "prawns" on the Internet that teach cainiao how to configure ISAPI support in IIS 7.x (or even the method of copying files to the system directory not recommended in the PHP Manual) to support PHP. This article describes how to enable FastCGI in IIS7.x and configure PHP.
My configuration environment is Windows 7x64 + IIS 7.5, but the content in this article should be completely common in Windows 7.x, because FastCGI has become a built-in component since IIS 7.0. For earlier versions, FastCGI support needs to be installed, and the configuration is slightly different.
Part I. Enable FastCGI support in IIS 7.x
Open in sequenceControl Panel | programs and components | enables or disables Windows, The English version of the corresponding operation isControl Panel | Programs and Features | Turn Windows Features On or Off. Then enable FastCGI as shown in the following figure (check CGI to enable both CGI and FastCGI support ). You should select other items based on your needs. I checked the items to highlight them.
If it is IIS7.0, Microsoft has released a series of upgrade patches to fix some of the known issues of the built-in FastCGI module. You can download the corresponding patches based on your system:
Update for Windows Server 2008
Update for Windows Server 2008x64 Edition
Update for Windows Server 2008 for Itanium-based Systems
Update for Windows Vista SP1
Update for Windows Vista SP1 for x64 based Systems
Part II. install and configure PHP
In Microsoft's official article, we recommend that you use the non-secure thread version of PHP (non-thread safe build of php). However, Zend Optimizer in this version is complicated to enable, most commercial PHP programs are inseparable from Zend Optimizer, so we recommend that you still use the secure thread version of PHP. Download the latest PHP Zip package from the official PHP website. This article uses PHP 5.2.9-2 and PHP 5.2.9-2 zip package.
After the download, decompress the package to any directory (in this article, use D: \ server \ php, and all the places that involve this path are represented[PHP Install Dir]), And rename php. ini-recommend in the directory to php. ini. Open the file in any text editor and check the following settings:
- Fastcgi. impersonate = 1
- Cgi. fix_pathinfo = 1
- Cgi. force_redirect = 0
- Open_basedirPoint to the path of the website containing the php program. [Optional]
- Extension_dir = "./ext"Note: In previous versions, the absolute path is often used here, but now you can use this method for general configuration.
- Delete the semicolon before the php extension add-on that you want to activate, for example:
Extension = php_mssql.dll
Extension = php_mysql.dll
Note: not all projects can be activated. It is best to activate only the items you need. If one item cannot run after activation, comment out the item and restart IIS.
After the settings are complete, you can start a command prompt window (cmd.exe) to run[PHP Install Dir]/php-infoCheck whether php runs correctly. If yes, a series of environment variable prompts are output.Part III. Configure IIS to process PHP requests
Open the IIS manager, select your computer on the left, and click"Handler Mapping"(The Chinese version of my friend compared to the one mark, I am not sure what the project will translate into in the Chinese version of the operating system), and then click"Add Module Mapping..."(Add module ing).
In the Add Module Mapping dialog box that appears, enter your own installation path (that is, Executable (optional)[PHP Install Dir]/php-cgi.exe):
Click OK. A confirmation dialog box is displayed, asking if you want to add the module ing. PointYesContinue.
This completes the installation of PHP in IIS 7.x. Create a text file under your website directory with the file name suffix. php, such as test. php, the file contains only one line:
<? Php phpinfo ();?>
Then browse the file in the browser (usually http: // localhost/test. php). Normally, the default information page of PHP is displayed.
According to different configurations, the information may be different. I have installed Zend Optimizer v3.3.3 In the screenshot here. By default, Zend Optimizer v3.3.3 does not exist. You can download and install it on your own, the installation of Zend Optimizer is the same as that of all previous versions. Even if there is no tutorial, you can install Zend Optimizer by following the installation wizard step by step. I will not go into details here. In addition, the installation of MySQL and PhpMyAdmin is the same. It is not related to the IIS version. I won't talk about it anymore.
Users who have previously configured PHP4 or configured it via ISAPI in earlier versions of IIS 6.0 can find that configuring PHP in IIS 7.x using FastCGI has been greatly simplified, you don't need to copy files to system folders like PHP 4, you don't need to modify environment variables like those in earlier versions of IIS 6.0, and you don't need to set the absolute path of extension_dir like the ISAPI method ......
All in all, in Windows, PHP is not just a thing that can't be done in the past. its security, stability, and running efficiency have been greatly improved. In addition to Linux + Apache + PHP + MySQL, we can now easily use Windows + IIS + PHP + MSSQL.