OK, now we are ready to test our PHP installation. Start by creating a simple PHP test file. Open Notepad on the server and copy the following line into a new text file :
<?php phpinfo(); ?>
Save the file as index.php in the root of the test web site. Next create a new default document type of index.php on the test web site (this step is optional but it just makes browsing a bit easier)
Browse to http://localhost (or http://localhost/index.php) and you should see the standard PHP configuration details page.
However, if you look carefully at the above page you will notice it is indicating that my ‘php.ini’ file is actually located in ‘C:\WINDOWS’ even though there is no such file in my C:\WINDOWS directory. This is because the ‘php5isapi.dll’ file is actually compiled with this location as its default value. A number of existing PHP and IIS tutorials suggest that you should copy the ‘php.ini’ file to the C:\WINDOWS directory – but what if you don’t want to do that ?
Well, you don’t have to because PHP allows you to actually configure a custom value for the ‘php.ini’ file location. There are a number of ways to do this but perhaps the simplest is to configure the PHPRC environment variable. Further details of how this works can be found here : http://uk.php.net/configuration
To demonstrate how this works I am going to create a new folder called ‘C:\inifile’ and instruct PHP to read its configuration data from the ‘php.ini’ file in this location (in practice you may prefer to leave your ‘php.ini’ file in the C:\PHP directory)
In order to do this I need to create a new System environment variable named ‘PHPRC’ and provide the appropriate values. Right-click on My Computer, click Properties and on the Advanced tab click Environment Variables.
In the Environment Variables dialog box, under System variables click New. In the New System Variable dialog box type PHPRC for the variable name and then enter the desired path to your ‘php.ini’ file’s location.
Then click OK and you will see that a new System environment variable has been created. In order for this to take effect you need to re-boot the server at this stage.
#Note – As an alternative, you can edit the registry and specify the location of your configuration file. The main benefit of the registry edit method is that it doesn’t require a re-boot – in testing this method I found that any changes made would take effect once the application pool serving the web site was recycled. However, choose whichever method you feel most comfortable with and which fits your requirements.
Now if we browse http://localhost we can see that PHP is indeed looking for its ‘php.ini’ file in the ‘C:\inifile’ location which we specified previously.
And that’s it. You should now have a working installation of PHP running on IIS 6.0. In the next article I will demonstrate how to install and configure MySQL with PHPMyAdmin on IIS 6.0 and then I will round off with a look at installing and configuring WordPress on IIS 6.0, which is what got me started down this road in the first place…