vote up 0 vote down star

I am using IIS as a webserver on my development machine for PHP webdevelopment. Or at least, I am trying to.

When there is a syntax error in a PHP script and I open that file in my webbrowser, I just get an 503 "internal server error" and the default IIS error page for this error. Some browsers dont open that file at all, possibly because of the 503 HTTP Response Header.

I would like IIS to act in that case just like the apache webserver: display the PHP file with the error anyway, so that the error message gets printed out.

How can this be done?

EDIT:

PHP settings:

display_errors

is on and

error_reporting

is set to E_ALL

flag

4 Answers

vote up 1 vote down check

With IIS7, it doesn't pass the errors through by default. It's "existingResponse" that needs to be set.

You can set it by running the following (make sure to replace {sitename} with your site name).

c:\windows\system32\inetsrv\appcmd.exe set config "{sitename}" -section:system.webServer/httpErrors /existingResponse:"PassThrough" /commit:apphost

link|flag
I tried this and Sam Cogans suggestion - it tells me the changes are done, but I still receive a "internal server error" instead of the php sript with error messages. Why did it not work? – Max Oct 1 at 15:29
Also turn off friendly error pages in IE if you haven't already. (Tools->Internet Options->Advanced) That can also mask the real message and is likely the secondary issue that you're running into now. – Scott Forsyth - MVP Oct 1 at 21:09
vote up 0 vote down

In your php.ini set:

error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT
display_errors = On

And if you want them logged:

log_errors = On
link|flag
Sorry, forgot to mention: PHP is configured to report and display errors. See my edit. – Max Sep 30 at 6:29
vote up 0 vote down

To enable detailed errors for PHP (and other languages), run this command from the command line:

%windir%\system32\inetsrv\appcmd.exe set config -Section:system.webServer/httpErrors -errorMode:Detailed

Then

IISReset
link|flag
vote up 0 vote down

A best practice would be to log "silently" in a file.

But you can have both by setting the following value in your php.ini file to a logfile

error_log=<File Location>
link|flag

Your Answer

Get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.