Skip to content

Instantly share code, notes, and snippets.

@smowtion
Forked from joerx/php-fpm-nginx-errorlog.md
Created July 24, 2018 18:59
Show Gist options
  • Save smowtion/0c5f5d36f16434ec259c4216478e87e9 to your computer and use it in GitHub Desktop.
Save smowtion/0c5f5d36f16434ec259c4216478e87e9 to your computer and use it in GitHub Desktop.
redirect php-fpm output to nginx's error log
  • php process is wrapped like this: PHP file -> php-fpm -> nginx
  • basically means disable all facilities that catch output from the script on it's way to nginx
  • standard error output will the end in Nginx's logging facility

On CentOS

  • make sure your script does not set error_log
  • edit /etc/php-fpm.conf, disable line error_log = /var/log/php-fpm/error.log
  • edit /etc/php-fpm.d/www.conf, disable line starting with php_admin_value[error_log] = ...
  • restart fpm: systemctl restart php-fpm
  • tail /var/log/nginx/error.log to see if it worked

On Ubuntu

  • pretty much the same, though php_admin_value[error_log] seems to be disabled by default

Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment