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

Max
  • 481
  • 1
  • 9
  • 17

5 Answers5

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
Burgi
  • 140
  • 13
Scott Forsyth
  • 16,449
  • 3
  • 37
  • 56
  • 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 01 '09 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 Oct 01 '09 at 21:09
1

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

ini_set('display_errors','On');

error_reporting(E_ALL | E_STRICT);
Frank
  • 11
  • 1
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
Sam Cogan
  • 38,736
  • 6
  • 78
  • 114
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
    >> 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. –  Apr 24 '13 at 18:54
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
rkthkr
  • 8,618
  • 28
  • 38
  • Sorry, forgot to mention: PHP is configured to report and display errors. See my edit. – Max Sep 30 '09 at 06:29