PHP-FPM doesn't write to error log

PHP-FPM doesn't write to error log

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

PHP-FPM Doesn't Write to Error Log

When setting up an Nginx and PHP-FPM stack, one of the most frustrating experiences is watching your error log remain stubbornly empty. You generate a fatal exception in a PHP script, see the red traceback immediately in your browser because display_errors is on, and even verify that Nginx has received the stderr output via its own access or error logs. Yet, when you inspect the file specified by php_admin_value[error_log], it stays silent.

In many production environments, this configuration seems to work perfectly: PHP-FPM writes to the designated log file, and administrators can debug issues without needing to inspect Nginx logs. However, there is a specific nuance in how PHP-FPM handles output streams that often leads to this "ghost logging" scenario. The culprit is rarely a missing library or a misconfigured directive; it is almost always an issue of ownership and file permissions.

The root cause lies in the distinction between what Nginx sees and what PHP-FPM can actually write. When Nginx proxies a request to the PHP-FPM socket, it forwards the error message via FastCGI. If your configuration uses catch_workers_output = yes (as seen in the provided fpm.conf), Nginx is explicitly configured to capture this stderr stream and log it to its own location. This explains why you see the errors in /var/log/nginx/error.log. However, capturing the output for logging is different from writing it to a file on the filesystem.

For PHP-FPM to write directly to a file defined by php_admin_value[error_log], the process running the PHP worker must have write permissions to that specific directory and file. The configuration snippet provided sets the worker user to webusr and the group to webusr. If the directory /var/log/php-fpm/default/ or the error.log file inside it is owned by a different user, or if the group has no write privileges, the PHP process will silently fail to open the file for writing.

Operating systems enforce these permissions strictly. Even if you attempt to force permissions using chmod 777, as suggested in some troubleshooting attempts, this can introduce significant security vulnerabilities and might still not resolve the issue if the specific user context (e.g., webusr) lacks ownership of the parent directory. The most reliable fix is ensuring that the directory and the log file are owned by the same user and group that PHP-FPM runs under.

To resolve this, you need to align the filesystem ownership with the process identity. Assuming your site owner is webusr, run the following commands:

chown -R webusr:webusr /var/log/php-fpm/default/
chmod 640 /var/log/php-fpm/default/error.log

It is crucial to note that while php_admin_value forces the path regardless of what your .htaccess or other directives say, the underlying OS permissions cannot be overridden by PHP configuration. If the worker process cannot touch the file, it will not write a single byte, leaving you with no record of the crash on disk.

This behavior highlights an important architectural trade-off in web server setups. Relying solely on catch_workers_output to debug PHP errors is convenient because it aggregates everything into the Nginx log, but it hides the fact that the PHP process itself was unable to persist its own logs. This separation of concerns means you are trusting the reverse proxy as your primary source of truth for application crashes, which can be problematic if Nginx logs are rotated or purged before an incident is investigated.

For high-reliability systems, it is best practice to ensure that the PHP-FPM worker process has direct write access to its own log files. This ensures that even if Nginx logging mechanisms fail or get corrupted, the application errors remain on disk for forensic analysis. Always verify that the listen.owner and user settings in your fpm.conf match the ownership of your log directories to prevent these silent failures.

Our network