PHP application can be hosted on IIS web server by using
FastCGI Module that can be found in IIS. Here I’m using IIS 7 as web server. Before moving for next step for how to host PHP on IIS (Internet Information Services) let’s take a look what is FastCGI Module? FastCGI is a standard protocol that allows the CGI executable files for application frameworks to interface with the Web server. It differs from the standard CGI protocol in that FastCGI reuses CGI processes for multiple requests, which provides a significant performance boost as compared to CGI. Support for IIS FastCGI enables IIS to host normal CGI programs like PHP or Ruby on Rails by using the FastCGI protocol, and to offer high performance and stability for production deployment of such application frameworks.
Now, to host PHP on IIS successfully you have to perform some following steps:
Step 1: Install IIS Web Server with CGI option in your system.
Step 2: Install PHP for Windows operating system in your system (For more details on PHP Installation click here)
Step 3: Configure PHP configuration file (php.ini) to work with IIS web server
Step 4: Configure FastCGI module to work with PHP
Manually Configure php.ini file to work with IIS web server:
To run PHP on IIS web server you have to make some changes in php.ini file. Let’s take a look about these changes:
Step 1: Set fastcgi.impersonate = 1
Step 2: Set cgi.fix_pathinfo=1
Step 3: Set cgi.force_redirect = 0
Step 4: Set open_basedir to point to that folder or network path where the content of the Web site is located.
Step 5: Set extension_dir to point to that location where the PHP extensions are located. Typically, for PHP 5.2.X the value would be set as extension_dir = "./ext"
Step 6: Enable the required PHP extension by un-commenting the corresponding lines, for example:
extension = php_mssql.dll
Manually Configure FastCGI Module to work with PHP:
To manually configure the IIS and FastCGI extension, you have to perform some following steps:
Step 1: Open Internet Information Services (IIS) Manager (to open IIS manager type ‘inetmgr’ in run command textbox)
Step 2: Double click on ‘Handler Mapping’ and select ‘Add Module Mapping’ from left Action Pane. After that filled appropriate information into textboxes.
Request path: *.php
Executable: "C:\[Path to your PHP installation]\php-cgi.exe"
Name: PHP via FastCGI
After this, just click on ok button.
Now IIS web server is ready for run PHP file or PHP web site.