PHP on Windows Server 2008 : 500 – Internal Server Error on IIS

Posted by iphp on Jan 26, 2009 in PHP Development |

Recently we had to work on a Windows server 2008 (web edition) machine with IIS 7.0 and we ran into the strangest of errors. The server stops running the script with this message :  

Server Error 
500 – Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed. Internal Server Error - Windows Server 2008
Cause:

This error happens on the default configuration of windows server 2008. The server logs do not say a lot except for the fact that the php file is causing an error. This happens for the following reasons on the server:

  • PHP Fatal error (Something that you did or didn’t do caused the server to run into a fatal error)
  • PHP error_reporting is on and there are some errors (Anything from a NOTICE or WARNING can cause this)

 
How to rectify:

Obviously the best way to resolve the error is find out what is wrong with the PHP code. But how do you do this if the server won’t show you what the error is? One of the best ways to find what is wrong with your PHP script is to try to login to the machine via RDP. This works only if you have remote desktop access. Once in RDP try to go to the same URL but using the server’s Internet explorer. Accessing the server locally will avoid the 500 Internal Server Error and show you what is wrong with the PHP file as on a development environment. The server just shows you the PHP error messages and the rest of your script output is not shown.

Change IIS 7.0 Setting
Alternatively to the above, you can always change the configuration using the Configuration Editor of IIS 7.0. You will find this under the Section > system.webServer/httpErrors. You have to change errorMode to Detailed 
from the usual DetailedLocalOnly and then click on Apply.

This is a good security measure as it will not accidentally show your PHP errors to the users of your system.

Tags: , ,

23 Comments

judgej2
Feb 9, 2009 at 2:16 pm

So scripting errors result in “500 Internal server error” rather than a scripting error? That’s handy.


 
ScottyDelicious
Feb 9, 2009 at 2:16 pm

IIS? Well, there’s your problem right there.


 
Andrew
Feb 10, 2009 at 4:26 am

Actually, that is a good security feature, because then it isn’t telling the public you have your PHP files at D:\hosts\mysite.com\phpapp\source.php.

PHP and IIS7 get along quite well, and I’m glad to see that. IIS7 is truly leaps and bounds ahead of previous IISes.


 
Morgauxo
Apr 24, 2009 at 8:25 pm

Good security feature, really?

It’s redundant. PHP already has that ability built in.

After a day of looking for the cause of the 500 errors on what is supposed to be a new development server with no outside internet access anyway I am not impressed by this feature.

Thanks for the post!


 
Sumbuddy
Jun 22, 2009 at 9:07 am

I had this error _before_ I got any php-script on the server, so where the heck’s the problem?
.. oh and I’ve got windows server 2k8


 
Sandman
Jun 23, 2009 at 6:29 pm

The problem is in the permissions of the wp-content folder. Was rebuilding a new 2008 IIS 7 with wordpress and found the same thing when uploading plugins. If you give IUSR writes ass to the folder it will correct the problem. Hopefully this helps someone else, it took me about and hour before I figure out where it was coming from as it didnt leave any understandle log errors.

If I can help let me know


 
FromApple.com
Jul 1, 2009 at 8:00 pm

Thanks for the post. It helped me and saved me LOTS of time. God Bless!

Keep posting things like this. Pleazzzzzzzzzzzzzzzz!


 
Isaac
Jul 24, 2009 at 9:44 pm

Yea!! I just need to give a modify permission to IUSR on the folder where my php error log location


 
uai user
Aug 11, 2009 at 9:11 am

Great article and a big help using the rdp option! Great!! Thanks a lot.


 
TopCoder
Sep 1, 2009 at 8:27 am

Thanks for the details of on to sort this out.


 
David
Nov 7, 2009 at 10:14 pm

Thanks for the pointer. It saved a few hours of mine.


 
ahsanhashmi
Dec 19, 2009 at 5:24 am

Thanks for the post.Keep posting things like this.


 
Mike Kingham
Jan 12, 2010 at 10:02 pm

It is worth mentioning that IE has an option to hide the details of a 400-500 type error and only return a generic message. You can turn this feature off under the Advanced settings: “Show Friendly HTTP error messages” By default this option is turned on. Turning it off will help you see the full error returned by the server. Thanks for the article, it was a big help!


 
Kopi Tribulusdynamic
Jan 26, 2010 at 11:17 am

Thanks :) . This worked for me in a roundabout way… I was just getting 500 errors on my modules page,when it wouldn’t load.


 
Ben Jamin
Feb 25, 2010 at 10:31 am

- Note –
I had the 500 internal error on a form post.

On SHARED hosting i.e. with Fasthosts, you CANNOT change the access to the folders as this would inherantly give you access to the other folders.

I had a problem with this and the only solution was to switch to Linux hosting, Fasthosts were telling me the it was a ‘script error’ however the script worked fine on one of my other servers (which was linux) after a couple of arguements with so called support in the philipeans they admitted that the php access permission on shared hosting cause problems! No Sh*t.

Switched to Linux – Problems Solved.


 
sixFroscofs
Mar 23, 2010 at 7:50 pm

i honestly enjoy your writing choice, very unique.
don’t give up and keep penning for the reason that it simply very well worth to read it,
excited to look over alot more of your current web content, thankx :)


 
Cody
May 4, 2010 at 9:23 am

And I was just about to migrate to IIS7 right after FreeBSD setup failed. Tried it out, our page came up and looked like shit so I turned on short tags thinking problems solved (usually the case), now its error 500 and nothing worked. Screw this. The permission bugs on this software are terrible.

Back to Apache 2.2 – Problems solved.


 
Alan
May 5, 2010 at 12:01 pm

To be honest I love iis its simple to use and efficent and supports both php and asp and asp.net which is more than I can say for linux, until linux sorts out its issues and starts supporting multiple languages IIS will always be the most popular server for the professional developer as its not about the tiny issues you people seem to always winge about its about having the most flexible server to accomplish many different tasks and those on shared hosting may I suggest private servers though more costly (tiny amounts more) the advantages vastly outweigh the negatives, I currently run a private server and 500 errors are still an issue but only take minutes to resolve due to event log access and general permissions access, I run php and asp sites as well as some asp.netr features and also some server apps that keep all of it ticking over this sort of setup could never be achieved with linux/unix but on windows it was litteraly a one day job to get php, mysql, and everything else working.


 
Ajmal tanha
Jul 12, 2010 at 5:48 am

Yaar I have also this erro but i use Asp.net what should i do to solve this problem.
can any one help mee.
Plzzzzzzzzzzzzzzzzzzzzzz……..


 
Garykva
Oct 29, 2010 at 2:14 pm

When I built a windows 2008 web server R2, I simply loaded PHP via windows platform installer. It will configure the server to use Fast CGI and it works seamlessly. You can also set up IIS on win2008 to use trace and identify errors. The Event logs are your friend, so ensure you look through those. I have been playing with IIS and PHP MYSQL for years. If a 500 error appears all of a sudden, its probably due to recent changes or some module not started. If you make changes, remember to stop the web site and restart it. Microsoft and Technet have IIS issue forums and there are MANY knowledgable people there, just presnt facts and hope they have an answer !

Gary K


 
Naveed
Nov 6, 2010 at 6:29 am

Thanks. It helped me to solve my problem.


 
Shane
Dec 7, 2010 at 1:10 pm

i just installed CGI last night on my W2K8 server with IIS7. now i get the same error. so if i’m reading this write. i may have given the wrong password when installing so the IUSER Password may be out of sync?


 
Val
Apr 6, 2011 at 6:55 am

Errors are sooo not helpful. As soon as I changed ‘localhost’ to the actual IP address for MySQL server instance and its port (e.g. ’123.123.123.123:3306′), everything started flying. It would’ve been nice to see something like “DB Server not found” or something…


 

Reply

Copyright © 2012 PHP, Web and IT stuff All rights reserved. PHP Web development in London.