Installing PHP With IIS To Create A Discussion Forum - Installing PHP (Page 2 of 5 )
Download the Windows binary for the latest version of PHP. 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(); ?>
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.