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.

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.