Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

5 Answers 5

up vote 3 down vote accepted

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

share|improve this answer
    
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 '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 - MVP Oct 1 '09 at 21:09

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>
share|improve this answer
    
>> 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 '13 at 18:54

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
share|improve this answer
    
Sorry, forgot to mention: PHP is configured to report and display errors. See my edit. –  Max Sep 30 '09 at 6:29

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
share|improve this answer

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

ini_set('display_errors','On');

error_reporting(E_ALL | E_STRICT);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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