7

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

5 Answers 5

5

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
2
  • 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?
    – BMBM
    Oct 1, 2009 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. Oct 1, 2009 at 21:09
1

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
1

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>
1
  • 1
    >> A best practice would be to log "silently" in a file. Not necessarily. There is nothing wrong with displaying errors on an internal development server. Just don't do it on your live server.
    – user171032
    Apr 24, 2013 at 18:54
1

Include the following two lines at the top of your PHP script

ini_set('display_errors','On');

error_reporting(E_ALL | E_STRICT);
0

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
1
  • Sorry, forgot to mention: PHP is configured to report and display errors. See my edit.
    – BMBM
    Sep 30, 2009 at 6:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .