Just a few thoughts, to start….
- I’ve tried to make this is as simple, and, comprehensive as possible. If you research this on the net here are slight variations for doing all of this, and presumably most of these variations work just fine. For instance, some people don’t copy certain files to locations that I recommend, some don’t add a registry entry for PHP, etc. Obviously, you can experiment, use different packages, and tweak things however you wish. This is simply my own outline.
- ISAPI PHP is not recommended on IIS 5, 6, or 7 by Microsoft as it is viewed as unstable. On the other hand, many people prefer it to the FastCGI installation – and it is still widely used by many people with IIS 6. And the reason for this is that ISAPI PHP is faster than FastCGI (whereas FastCGI is faster than CGI).
- On rare occasions you may see an error message that a “IIS Worker Process has stopped working”. This does not effect people viewing your web server’s pages and it is a very, very strange bug; I’ve done this installation and never had this error occur (with a server running day and night, for almost a year), and then – on other installations – I’ve had it happen now and then. It’s a completely inconsequential “problem” that, in my view, is safe to ignore. For example, on my most recent installation of IIS 6 with PHP I’ve seen this error one time, in a month.
Here are some files for download that you can use as you go through these steps. Either version of MySQL is fine. The “pre-configured” php package has a php.ini file that already contains common edits. The “test pages” are .asp, .aspx, and .php pages which you can use to make certain your server is correctly parsing various file types.
Some helpful batch files
Test Pages – .asp, .aspx, & .php
- Go to Server Manager and choose to add a role. Choose to add the Application Server. You can choose to enable ASP and Frontpage extensions – I enable them.
- OPTIONAL: If you want indexing to be enabled in IIS, first, go to Control Panel > Add/Remove Programs > Windows Components and you’ll see a tick box – tick the box….obviously. Then…..to enable indexing.
- To finish up with indexing in IIS open the IIS Manager and go to (1) Web Service Extensions and enable Indexing, and, (2) go to Web Sites, or, specific web sites, and tick the box seen below (labeled “Directory Browsing“):
- OPTIONAL (if you’re going to install Exchange): Okay – this really has nothing to do with IIS 6 and has no business being in this list. But, I eventually install Exchange and I always forget to do these steps – so this is just a little personal reminder. When finished, go to Control Panel > Add/Remove Programs > Windows Components. Go to Application Server > IIS > and enable SMTP and NNTP.
You’ll probably want to change the name of your default website site to something other than “default website” (in other words, change it to a real, usable web site with a domain name). To do this go to the the IIS Manager and right-click on the web site. To make things simple, just glance at the following 2 pics – they explain things better than my writing (note: I think “logging” is disabled by default – you should enable logging) – in the example I have changed the default web site to “webputzer.com”:
Enabling ASP Pages
I always panic, after I install IIS 6, because .asp pages won’t display. The problem – which is something that I always forget – is that .asp pages don’t simply work, when your installation if finished, like an .aspx page. I have a Unix/Linux background and I don’t really have experience with these types of pages – so I don’t know why one works, and, the other requires some “fiddling”. Anyway, you need to make sure that the following settings are in place……
- In Add/Remove Programs > Windows Components > Application Server make sure that ASP.NET is ticked….
- In the IIS Manager right-click Web Service Extensions and make sure that:
- Active Server pages is set to ALLOWED
- ASP.NET is set to ALLOWED
- Make sure that you add .asp pages as allowed documents – fairly self-explanatory (see graphic):
- This has been a real problem, for me, and I don’t know if it’s because I’m doing something wrong in the installation or if this is simply how IIS 6 is supposed to work – but I find it very odd: immediately after IIS has been installed the ASP.NET service is (1) off, and, (2) set to start manually. Obviously, you need to start this service and set it to “Automatic”….
Starting and Stopping IIS 6
IIS can be start, stopped, and restarted from a command prompt with the following commands:
And, oddly enough, I always forget where IIS 6 can be started and stopped using the IIS Services Manager’s GUI. Highlight the computer, right-click, choose All Tasks, then Restart IIS (as seen below):
Adding PHP and MySQL
This little guide includes downloads for PHP and MySQL – there’s a shortcut to the MySQL command line client in the zip archive (with the installer – version 5.5.16-win32)…..
While there are downloads offered on this page, obviously, you can use different versions of PHP and MySQL.
- Download one of the following PHP packages – the edited version has been modified to load common modules, the timezone is set to America/New York, the log file is set to C:\php_error.txt, etc. - if you download the pre-configured version some of the steps for setting up php, below, can be skipped (the edits are already in place in php.ini):
- Download MySQL:
- Create a folder at C:\php. Unarchive the downloaded php zip file and copy the contents of this file to C:\php
- Copy php5isapi.dll (from C:\php) to both C:\WINDOWS and the system32 directories (the latter – system32 – is optional and should not be needed)
- Go to C:\php and rename the php.ini-recommended file to, simply, php.ini
- Edit the php.ini file and set the extension directory, thusly:
extension_dir = C:/php/ext/
- Edit the php.ini file and uncomment the following to load modules (obviously, what you load is at your discretion):
- Copy your edited php.ini file to C:\WINDOWS\php.ini
- Go to My Computer > Properties > Advanced > Environment Variables and choose the “path” variable to edit. Add the following at the end of the existing entry:
The above is very important (don’t forget the semi-colon)
- Go to C:\php\ext and copy php_mysql.dll, and, php_mysqli.dll to both the WINDOWS and WINDOWS\system32 directories. Go to C:\php and copy the libmysql.dll to both the WINDOWS and WINDOWS\system32 directories.
- From a command prompt run regedit and add the following php entry to the registry (alternatively, just download this file and double-click):
HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath = C:\php
- Unarchive and install MySQL. The MySQL installation is a very straightforward Windows installation. I would recommend choosing a “Standard Configuration” (as opposed to the default, “Detailed Configuration”) and – beyond that – simply choose to run MySQL as a service and set a password – that’s it.
Configure IIS to use PHP
Note: I’ve done the first two steps in reverse order – it really doesn’t matter which you do first.
- Enable the .php file extension on Web Sites: Go to the IIS Management console and highlight “Web Sites”, right-click, then choose “Add A New Web Service Extension” from the menu. 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). After you’ve applied this change, by the way, .php may appear grayed out if you double-check your entry. if you do the first two steps, here, in reverse order it will not appear grayed out – and it doesn’t matter. 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.
- 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:
<?php phpinfo(); ?>
Basically, you should now be good to go – your server capable of hosting a wide variety of pages (.asp, .aspx, .html, .php and so forth). And to make testing everything simple, you can download these TEST PAGES (.php, .asp, and .aspx) to double-check that everything is running as it planned.
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, and, presuming you added the phpinfo page which I recommended). Again, by copying the other test pages into your wwwroot folder you can load them in your browser to make certain that the various file types are parsing correctly. Good luck, and, I hope this helps some people.