Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display PHP Errors in IIS

Tags:

php

iis

I am trying to get PHP errors to display on the screen using IIS vrs 8.5 and PHP vrs 5.2.17, but I continue to get the IIS 500 error http page, or a blank screen. I have already found numerous SO posts that have supposed fixes, but nothing on them has fixed my problem yet. Here is what I have tried.

  • Changed errorMode to Detailed. Still getting the 500 error page instead of the php error.
  • Removed all of the custom errors in the default IIS config file under the "httpErrors" block. Still getting the IIS custom 500 error page.
  • Added existingResponse="PassThrough" to my httpErrors block in the default IIS config. Doing this causes me to get a blank page instead of the php error, or the IIS 500 error.
  • I have verified that none of these settings are being overwritten in the site default system.config files.

Currently I am getting a blank page instead of the IIS 500 error on the screen. I have already verified that display_errors is on, and error_reporting is correct. I also know that the php page runs just fine. I am purposely causing this php error by removing a semi-colon on the page. So I already know everything is working fine. PHP Error logging is also working, but I want the errors to display on the page so I dont have to look at the error log every 5 minutes.

What else could be causing this?

like image 900
Metropolis Avatar asked Dec 22 '14 18:12

Metropolis


People also ask

How do I display PHP errors?

Quickly Show All PHP Errors The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);

How do I troubleshoot PHP errors?

To view the errors in your PHP application, you will need to set the following settings in your PHP page so you can troubleshoot the problems. Knowing how to configure PHP display errors is really important. ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);


2 Answers

IF you set custom error to Detailed in feature settings of error pages for website and server both

AND if in your php.ini file you set the display_errors = on & error_reporting = E_ALL

THEN there is only one possibility for getting [IIS default 500 error page] is that "Your PHP is not working coz of miss configuration."

The required configurations are:

After setting Handler Mappings to your php-cgi.exe file(which is in you php installation dir) as FastCGI, open the php.ini file and edit following lines OR add if not found in file. (if php.ini is not exists in you PHP installation dir then rename from existing php.ini-development OR php.ini-production)

1) extension_dir = "ext\"

;ext folder will be in PHP installation, if not create and don't forget ending \

2) log_errors = On

3) error_log = "C:\inetpub\temp\php-errors.log"

4) cgi.force_redirect = 0

; may be you need to add this line add it anywhere, for instance-before '; File Uploads ;'

5) cgi.fix_pathinfo = 1

6) fastcgi.impersonate = 1

7) fastcgi.logging = 0

 Be careful and there should not `;` before any of these lines.

see documentation - installing/configuring PHP

Even after correct configurations PHP may not work because of system corruption. You can check by double click on php-cgi.exe and php-win.exe it should run without proper error (other then warnings OR ext/fileName... is missing messages - these are OK).

Note: after these many other setting are requires to run all things of php (ex. session), but by these SIMPLE PHP WILL WORK or PHP will properly show the error for what's wrong (NOT 500 page).

like image 151
Adarsh Rajput Avatar answered Oct 29 '22 06:10

Adarsh Rajput


Make sure you are editing the right php.ini file. To check which file needs to be edited, go to IIS > Handler Mappings and look for PHP. Then check which directory they are located in.

In my case, I had two directories and was editing the wrong php.ini file, which was the reason why I was unable to get the errors to display.

like image 1
Nikita Bernstein Avatar answered Oct 29 '22 06:10

Nikita Bernstein