How to host PHP on windows server IIS 8

How to host PHP on windows server IIS 8

PHP application can be hosted on the IIS web server by using FastCGI Module that can be found in IIS. Here I’m using IIS 7 as a web server.

Before moving for the next step for how to host PHP on IIS (Internet Information Services) let’s take a look at what is FastCGI Module?

The FastCGI is a standard protocol that allows the CGI executable files for application frameworks to interface with the Web server.

This 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.

Where the 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 the 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 the 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 the IIS web server you have to make some changes in the php.ini file. Let’s take a look at 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 uncommenting the corresponding lines, for example:

extension = php_mssql.dll

extension=php_mysql.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

Module: FastCgiModule

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.

Last updated:2/23/2020 11:58:58 PM
Arun Singh

Arun Singh

Software Developer

1 Comments

Leave Comment