Running PHP on IIS 6.0

How I finally set up PHP on IIS after years of trying and what steps actually worked

Posted by Hüseyin Sekmenoğlu on January 09, 2012 Backend Development

⏳ Some Things Just Take Time

I had been trying to run PHP on IIS for four years. Today I managed to do it in just five minutes. Maybe everything has its time. It reminded me of the time I tried to create my own SSL certificate. That took me two years to figure out as well.

Now let us return to the topic.


🔍 The Real Problem

I had probably been skipping some essential programs required for PHP to run properly on IIS. Recently I dug through many websites and finally found a YouTube video series that explained everything clearly. It turns out installing the necessary programs is harder than installing PHP itself.

To avoid watching videos again next time, here is a list of tools and configuration steps that worked for me.


📦 Required Software

  • PHP for Windows

  • Microsoft C++ Runtime (the site mentions 2008 but newer versions also work)

  • FastCGI for IIS

  • Microsoft SQL Server Management Studio Express

  • Microsoft SQL Server

  • MySQL for Windows

  • phpMyAdmin


🛠️ PHP Configuration

After installing all software, locate the PHP folder. You will see a file named php.ini-production. Rename it to php.ini and open it.

Now apply these changes:

  1. Find the Paths and Directories section.

    • Uncomment the include_path line

    • Change the path to:

include_path = "c:/php/pear"
  1. Uncomment the doc_root line and update it to your website's root directory.

  2. Find the extension_dir variable.

    • Uncomment it

    • Set the path:

extension_dir = "c:/php/ext"
  1. Find and uncomment:

cgi.force_redirect = 0
  1. Uncomment this line as well:

fastcgi.impersonate = 1;

Save and close the php.ini file.


🌐 IIS 6.0 Setup

Now move on to IIS settings:

1. Enable PHP as an Extension

  • In IIS Manager, under Web Server Extensions, right-click and select Add New Extension.

  • Name the extension php.

  • Click Add, then browse to and select:

php-cgi.exe
  • from your PHP installation folder.

2. Add PHP to Default Web Site

  • Right-click Default Web Site > Properties > Home Directory tab.

  • Click Configuration.

  • In the opened dialog, click Add.

  • Again, browse and select php-cgi.exe.

  • In the Extension field, type:

php

Click OK to close all dialogs.


✅ Final Test

Create a new file in your website folder and name it:

index.php

Inside the file, paste this code:

<?php phpinfo(); ?>

Now open your site in a browser. If everything works, you will see PHP information displayed. That means your setup is successful.