Skip to content

Instantly share code, notes, and snippets.

@joerx
Last active August 6, 2023 16:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joerx/87c6755023d2817154b41264311fcfe6 to your computer and use it in GitHub Desktop.
Save joerx/87c6755023d2817154b41264311fcfe6 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

@andyexeter
Copy link

Thanks for this!

@RoyBellingan
Copy link

Thank you!

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