IIS with PHP5 (dso ver.) and MySQL

Note: this post is not here because I am an authority on this subject. It’s here because I am brand new to IIS, etc. and when I got this working I figured I’d better write down what the hell I’d done. I am the opposite of an authority on this subject – I am an idiot. But, this is what worked for me.

Originally, here, I had copied and pasted a page from the internet which purported to show how you install php5 on Windows Server 2003 and IIS. Maybe the thing was accurate, but, I couldn’t get anything to work following the instructions. And I’d found other pages, as well, that failed to work. Some appeared to be missing steps, some were highly detailed and included optional, recommended steps. The latter were hard to follow, and, just following the basic steps the darned thing still failed to work. Finally, I found a video on YouTube and – to a large extent – I just did exactly as the video instructed. Actually, I did a couple of inconsequential, extra (probably unnecessary) things and the darned thing immediately worked. Finally! I’m not at a Windows Server 2003 desktop but here’s what I recall, and, a few random notes. I’ve also added a MySQL download, below. It’s easy enough to find but I don’t wanna have to fishing for the thing – there’s a shortcut to the command line client in the zip archive (with the installer – version 5.5.16-win32):

The Steps

  • I used php-5.2.5-Win32.zip (click the link to download the package)
  • And I used this version of MySQL: Download mysql-5.5.16-win32
  • I used the above versions simply because that’s what some net video used – they’re not the most current versions and you could try this with newer releases – I would presume it should all work the same way…..
  • I created a folder at C:\php and copied the contents of this php zip archive to that location
  • I copied php5isapi.dll (from C:\php) to both C:\WINDOWS and the system32 directories
  • I renamed the php-ini-recommended file (from C:\php) to php.ini and copied it to C:\WINDOWS
  • I went to My Computer > Properties > Advanced > Environment Variables and chose the “path” variable to edit. I added the following at the end of what already existed:
    The above is very important (don’t forget the semi-colon) – see next item.
  • According to a post which I read on the net (somewhere) IIS – or Windows Server 2003 – does not pay any attention to a common edit in php.ini that I’ve done with Apache on Windows XP, which worked. That edit amounts to uncommenting and editing a line to read exactly like the following (no quotation marks – this is copied and pasted from my php.ini file):
    extension_dir = C:/php/ext/
    With Apache on Windows XP this works to get the web server to load the various modules.
    In fact, on Windows Server 2003 php would not load various things which I’d uncommented in php.ini with only this edit. It started working, only, when I’d edited the path as described in the preceding list item. And, just for the record, I left this in place in the php.ini file – it may not even be required. That’s something which is unclear to me – but it won’t hurt anything, and, it worked fine with this edit in place. So: I would find this line and change it to read as I’ve just described –even though it may not be required.
  • I uncommented the following in php.ini to load modules, and, it all worked (obviously, what you load is at your discretion):

Configure IIS to use PHP

  • Add/Map the php extension: Go to the IIS Management console and highlight “Web Sites”, right-click, then choose “Add A New Web Service Extension” from the menu. If I recall correctly – and I’ll update this later – there will be tabs from which you should consecutively select “Home Directory” and, then, “Configuration”. After having navigated this far you use the “browse” function to load “C:\php\php5isapi.dll” and add the file extension “.php” (no quotation marks – this is simply an attempt to make this page grammatically correct). After you’ve applied this change, by the way, .php will appear grayed out if you double-check your entry. I thought I’d done something wrong, possibly, when I applied this – the first time – and that was grayed out (I worry too much). Now, the IIS server knows how to process PHP files. However, it’s “Web Service Extensions” rules still restrict it from actually letting the server host/display php files. UPDATE: I just did this entire install, for a second time, and there was the following minor issue. I recalled that I added the PHP extension – as detailed above – by simply right-clicking on “Web Sites”. I actually had to repeat the process, detailed above, for the default website. Maybe this has to be done on a site by site basis. But, with this addition, everything worked – again.
  • Add a Web Server Extension: Go to the IIS Management console and highlight “Web Server Extensions”, right-click, then choose “Add A New Web Service Extension” from the menu. Hit “ADD” – which will allow you to browse – and, again, choose to load the “C:\php\php5isapi.dll” file. Name the extension PHP. The “Set extension status to Allowed” option MUST BE TICKED, also – click APPLY.
  • Adding the PHP document type: Returning to “Web Sites Properties” dialogue shown in we need to select the “Documents” tab and click on “Add”. To ensure that index.php documents open as a default they should be added as a “Content Page”. In other words, you should add an entry called “index.php” – like so:

    You can, of course, change the importance of PHP over ASP and HTML documents to suit your site based on which document type should take preference. Just move the php document type up the hierarchy as desired.Essentialy you’re done. I would recommend, however, doing the following step and rebooting your computer to just “kick out the cobwebs…”.

  • OPTIONAL/RECOMMENDED: I normally move the php extension to the top, in the preceding step, and add a php info page as “index.php” in the root directory of the default web site. In other words, open a text editor and use the following code to create a file called “index.php”; place the file in the document root directory of your default web site:

    Now, reboot and when you’re up and running again open your browser and enter “localhost” for the URL – this will show you all of the information regarding your PHP installation (presuming it’s working). If it fails to display, heck, I dunno. I’ve only tested this once – but it should work!

    UPDATE: Just to simplify, here are some TEST PAGES (PHP, ASPX, ETC) that you can use to check out your server (make certain it is parsing various extensions properly).
    That’s it.

Leave a Reply