So long before IIS 7.0, Microsoft has provided a more streamlined way of running PHP on IIS--fastcgi. But until IIS 7.5 comes along with Windows 7, there are a lot of "prawns" on the web that teach the rookie how to support PHP under IIS 7.x, in a way that configures ISAPI support (even the way it is not recommended in the PHP manual to copy files to the system directory). This article describes how to enable FastCGI in iis7.x and how to configure PHP.
My configuration environment is windows 7 x64 + IIS 7.5, but the content of this article should be completely generic in the Windows 7.x version because FastCGI is the built-in component from IIS 7.0. As for previous versions, additional installation FastCGI support is required and configuration is slightly different.
Part I. Enabling FastCGI support in IIS 7.x
Turn on the Control Panel | Programs and Components | Turn windows on or off , and the English version corresponds to the controls panel | Programs and Features | Turn Windows Features on oroff. Then, as shown in the following illustration, enable FastCGI (tick CGI will also enable both CGI and FastCGI support). Other items you should choose according to your own needs, I am here to highlight the other items to remove the tick.
If it's IIS7.0, Microsoft has released a series of upgrades to fix some of the problems that are known to the built-in FastCGI module, and you can upgrade your system by downloading the corresponding patches:
Update for Windows Server 2008
Update for Windows Server 2008 x64 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. Installing and configuring PHP
Microsoft's official article recommended the use of non-thread version of PHP (non-thread safe Build of PHP), but due to this version of the Zend Optimizer is more complex to enable, and most of the commercial PHP programs are inseparable from Zend Optimizer , so it is recommended that you still use the thread version of PHP. Please download the latest version of the PHP ZIP format compression package from the official PHP website , this article is written in PHP 5.2.9-2 version, download address:PHP 5.2.9-2 zip package .
After downloading, unzip it to any directory (using D:\server\php in this article, all of which are represented as [php Install Dir]), and then rename the Php.ini-recommend in the directory to Ini. Open the file with any text editor to find and confirm the following settings:
- fastcgi.impersonate = 1
- cgi.fix_pathinfo=1
- cgi.force_redirect = 0
- Open_basedir points to the Web site path that contains the PHP program. "Available Options"
- Extension_dir = "./ext" ; Note: In previous versions it was often used to use absolute paths, but it is now possible to make generic configurations in such a way.
- Remove the semicolon before the PHP extension add-in you need 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 what you use, if the activation of an item will not run, please comment out the key and restart IIS.
After setting up, you can start a command prompt line window (cmd.exe), run [php Install dir]/php–info Check whether PHP can run correctly, if correct, will output a series of environmental variables prompts.
Part III. Configure IIS to process PHP requests
Open IIS Manager, select your computer on the left, the middle window click "Handler Mapping" (Chinese version of the friend to control the icon, I am not sure what the project will translate in the Chinese version of the operating system), and then click on the right "Add Module Mapping ..." ( Add module mappings ).
In the ADD Module Mapping dialog box that pops up, follow the image below (executable (optional) Please fill in your own installation path, that is, [PHP Install dir]/php-cgi.exe ):
After completing, click OK, will pop up a confirmation dialog box, ask if you really want to add this module mapping. Click Yes to continue.
This completes the installation of PHP under IIS 7.x, creating a text file in your site directory, with a filename suffix of. PHP, such as test.php, which has only one line of content:
<?php phpinfo ();?>
Then use the browser to browse the file (usually http://localhost/test.php), and normally you will see the default information page for PHP.
Depending on the configuration, see the information may be different, I have the capture map has been installed Zend Optimizer v3.3.3, the default of course, you can download and install, Zend Optimizer installation and all previous versions of the same, even if there is no tutorial, Follow the installation Wizard one step at a while to install successfully. I will not go into the details here. In addition, there are MySQL, phpMyAdmin and other installation, are also the same. Although relevant, it has nothing to do with the IIS version. Will not talk about it.
Friends who have previously configured PHP4, or who have been configured as ISAPI in the previous version of IIS 6.0, should be able to find that using the FastCGI method to configure PHP in IIS 7.x has been greatly simplified, without copying files to the system folder like PHP 4, without having to do the same as IIS 6.0 The previous version modifies the environment variable, and it does not set the absolute path of the extension_dir like the ISAPI method ...
All in all, PHP is no longer just a thing that is not able to be done in Windows like before, and its security, stability, and operational efficiency have been greatly improved. In addition to Linux + Apache + php + MySQL, we can now also easily use Windows + IIS + php + MSSQL.