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

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

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.

Also read...


  1. judgej2 said on :

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

  2. ScottyDelicious said on :

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

  3. Andrew said on :

    Actually, that is a good security feature, because then it isn’t telling the public you have your PHP files at D:\hosts\\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.

  4. Morgauxo said on :

    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!

  5. Sumbuddy said on :

    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

  6. Sandman said on :

    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

  7. said on :

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

    Keep posting things like this. Pleazzzzzzzzzzzzzzzz!

  8. Isaac said on :

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

  9. uai user said on :

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

  10. TopCoder said on :

    Thanks for the details of on to sort this out.

  11. Pingback: David

  12. ahsanhashmi said on :

    Thanks for the post.Keep posting things like this.

  13. Mike Kingham said on :

    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!

  14. Kopi Tribulusdynamic said on :

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

  15. Ben Jamin said on :

    – 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.

  16. sixFroscofs said on :

    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 🙂

  17. Cody said on :

    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.

  18. Alan said on :

    To be honest I love iis its simple to use and efficent and supports both php and asp and 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.

  19. Ajmal tanha said on :

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

  20. Garykva said on :

    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

  21. Naveed said on :

    Thanks. It helped me to solve my problem.

  22. Shane said on :

    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?

  23. Val said on :

    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. ‘’), everything started flying. It would’ve been nice to see something like “DB Server not found” or something…

Comments are closed.