Huh. So you just installed PHP and now you can’t seem to get it working? This particular issue just hit me working with my Windows 2003 server. I have added a new developer that favors PHP. Since I really am NOT a PHP developer, I have occasionally installed PHP to just play, but on my current server, I hadn’t installed it. I HAD installed it on my “throwaway” Win2k IIS test server and it worked beautifully right off the bat. But on my main server, 404 errors.
The only way to figure it out – short of saying heck with it and running all PHP sites on the throwaway – was to do some basic troubleshooting.
- Did the file exist? Yup.
- Was URLSCAN blocking it? Nope.
- This was a new site on IIS, so would it serve out of another site that was known good? Nope.
- If I took a known working file and modified it to be an html file, would it serve? Nope.
- Perhaps it is a restart issue since I had JUST installed PHP? Nope.
- How about deleting the new site (which I had created BEFORE installing PHP via the MS Web Platform installer) and re-creating it? Nope.
- Hey, how about the mapping for PHP? Is it even there? AHA!!! NOPE! (Checking the mapping is actually explained in the paragraph below if you don’t already know how…)
It existed on the WORKING throwaway server, but NOT on my primary development server! There are two ways that this can actually be implemented – either on a site basis or on a server basis. I think by default that the Web Platform Installer would normally install on a server wide basis – but it hadn’t happened in this case. Either way the fix is roughly the same. If you wish to install the PHP mapping on a server-wide basis, you will just right-click on the “Web Sites” folder in the IIS MMC snap in. For just a particular site, then open up the “Web Sites” folder and start by right clicking on the individual SITE name that you wish to install PHP mappngs. Whichever way you go, then proceed as thus from the context menu: Properties => Home Directory (tab) => Configuration (button) => Mappings
Now, scroll down through your Application Extensions window and look for “.php”. If it’s not there, then odds are good that the problem is now quickly within your grasp. Click “Add” (button) and then find your executable – mine from the MS Web Platform standard install routine was “C:WINDOWSsystem32inetsrvfcgiext.dll”. The MS routine sets up the server to use the FastCGI method of PHP. If you are NOT using this method, then you’re on your own as this blurb only explains how to straighten out the absence of mapping for the FastCGI routine – but I bet it’s pretty similiar for a standard PHP install. Now add the “.php” extension and limit your verbs to “GET,HEAD,POST”. Apply and Okay on out. If you did this on a server wide basis, you will probably get a popup about other sites that this might affect – you are free to select individual sites to apply the mapping to or not depending on your needs and preference. Now test.
At this point, I got a new PHP error –
The FastCGI Handler was unable to process the request.. Excellent – at LEAST I was getting a new error indicating that the PHP file was being found! It is sad that getting a new error is a step in the right direction. BUT – check the following file – C:Windowssystem32inetsrvfcgiext.ini. Now you need to see that the [TYPES] area of the ini file actually DOES have correct mappings…
[Types] php=PHP [PHP] ExePath=C:Program FilesPHPphp-cgi.exe InstanceMaxRequests=10000 ActivityTimeout=300 RequestTimeout=300 EnvironmentVars=PHP_FCGI_MAX_REQUESTS:10000,PHPRC:C:Program FilesPHP
If you don’t see something similar at the bottom of your file, then more or less copy and paste the code block in there. Just make sure that YOUR directories and executables are in the same place as the example. Now, test again.
With any luck, you will be greeted with a now working PHP page. But if you’re me, then you may have had a fairly aggressive setting on your server about running unknown programs and blocking them. Once THAT was out of the way, I was treated to a now active PHP page setup! Thank God.
I hope this helps someone else. I get so antsy about messing around with programs that are supposed to install and just work – and then when they don’t, there’s no real idea of why not. These automated setup programs are GREAT when they work, but a real pain when you have NO idea what they were supposed to be doing – and you have to figure it out.