Search code examples
phpnginxerror-reporting

Display PHP errors on only one site


I've got a dev environment and a live environment running on the same host, using nginx with fastcgi. In php.ini, display_errors is set to off, so that the errors aren't displayed on the production site.

Now, on the dev environment, I need to be able to see those errors. So I'd do ini_set('display_errors', 'On');, however, if it's a parse error, that won't be executed and the error won't be shown.

So my question is, is there any way I can safely set display_errors to on in my php.ini file, and then maybe use the virtual host file in nginx to make sure that the errors aren't shown on the production site?


Solution

  • If you are using fastcgi you could configure it to run php with different php.ini files. I'm not familiar with nginx and fastcgi config, so can't provide you any hint on that. See php manual to learn how PHP could be run.

    I think you might want to run it like php -d display_errors=On for dev environment