Using PHP and IIS to Create a Discussion Forum

Installing PHP

Download the Windows binary for the latest version of PHP. Note that you can either download the installer package, which will automatically configure IIS for you (allowing you to skip this page), or download the zipped version - in which case, follow these instructions.

Once you've downloaded it, unzip it io a C:\ and rename the folder to "php".

Open the PHP.INI-DIST file from C:\PHP folder and locate the following line:

;cgi.force_redirect = 1

We need to uncomment this line and change the setting to 0 as shown below to run PHP under IIS. Make the necessary changes and save the file as php.ini in your Windows folder (C:\WINNT on my computer):

cgi.force_redirect = 0

Configuring IIS for PHP

I will assume that your IIS web server is up and running. Click Start -> Settings -> Control Panel -> Administrative Tools -> Internet Service Manager:

Select the default web site, right click on it and select the properties option:

Select the home directory tab and click on the configuration button. In the application configuration window, select app mappings and click on the add button.

Enter the location of the executable as C:\PHP\PHP.EXE (or the location where you have installed PHP) and the extension as .php, as shown in the diagram above. Lastly, click on the OK button. This configures IIS to recognize and run PHP files using the PHP interpreter.

Open your favorite text editor and create a text file. Type the following code:


phpinfo() is a PHP function which outputs a large amount of information about the current state of PHP. This includes information about PHP compilation options and extensions, the PHP version, server information and environment, the PHP environment, OS version information, paths, master and local values of configuration options, HTTP headers, and the PHP License.

Save this file as test.php in C:\INETPUB\WWWROOT (or your IIS Web Root Folder). Open you browser and visit http://localhost/test.php in the address bar. You should see a screen like this if PHP is running correctly:

If the source code appears in the browser and not the output like that shown above, then PHP has not been properly installed or IIS does not recognizes PHP files. Double-check your settings in IIS as this is usually what stops the PHP files from being parsed. Now that PHP is setup, let's look at creating a simple forum using PHP and an Access database.

You might also like...


About the author

Jayesh Jain

Jayesh Jain New Zealand

Jayesh Jain is working as a Business Analyst in Auckland, New Zealand. He has several years of n-Tier development experience in developing interactive client solutions. He has a passion for Web ...

Interested in writing for us? Find out more.


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“An expert is a man who has made all the mistakes that can be made in a very narrow field” - Niels Bohr