Getting PHP-FPM Error Log Directory for Each Script

Abstract: Locate the error log file path for each PHP-FPM pool by inspecting the error_log directive in the corresponding configuration files.

Created: 2026-08-03 by

To locate the error log directory for each PHP script running under PHP-FPM, inspect the error_log directive within the specific pool configuration file located in /etc/php-fpm.d/ or /etc/php/*/fpm/pool.d/. The path defined there is where all errors for that particular pool are written. You can also verify the active configuration using the php-fpm -t command to ensure the settings are valid before restarting the service.

Understanding PHP-FPM Pool Configuration

PHP-FPM (FastCGI Process Manager) operates by managing multiple pools of worker processes. Each pool is designed to handle requests from a specific virtual host, domain, or application context. This architecture allows administrators to isolate resources and logging for different parts of a web server. For instance, a production site might run in one pool while a staging environment runs in another, each with its own distinct error handling policies.

The configuration for these pools is stored in individual files, typically named after the pool itself, such as www.conf, blog.conf, or api.conf. These files reside in system-specific directories depending on your Linux distribution or macOS setup. On Debian-based systems like Ubuntu, you will often find them in /etc/php/8.1/fpm/pool.d/. On Red Hat-based systems like CentOS or Fedora, they are commonly located in /etc/php-fpm.d/. Understanding this structure is the first step in diagnosing where logs are being sent.

Locating the Configuration Files

To begin troubleshooting, you need to identify which configuration file corresponds to the PHP script causing issues. If you are unsure which pool is handling a specific request, check your web server configuration (Nginx or Apache). In Nginx, look for the fastcgi_pass directive pointing to a Unix socket or TCP address. This address usually matches the listen directive in one of the PHP-FPM pool configuration files.

Once you have identified the relevant pool file, open it with a text editor. Look for the line that begins with error_log. This directive explicitly defines the absolute path to the file where PHP-FPM will write error messages. If this line is commented out or missing, PHP-FPM may default to syslog or a standard location depending on the global configuration, but specifying it explicitly is best practice for clarity.

Interpreting the Error Log Path

The value assigned to the error_log directive is not necessarily a directory; it is a full file path. For example, a setting might look like error_log = /var/log/php-fpm/myapp-error.log. In this case, the "directory" is /var/log/php-fpm/, and the specific log file is myapp-error.log. It is crucial to understand that PHP-FPM does not automatically create subdirectories if they do not exist. Therefore, the parent directory must already be present and writable by the user running the PHP-FPM process.

If you are managing multiple domains, each domain should ideally have its own pool configuration file with a unique error_log path. This separation prevents log files from becoming unmanageably large and makes it easier to filter errors specific to one application. When debugging, always check the file specified in the pool config rather than assuming a global log location.

Verifying Permissions and Ownership

Even if the correct path is defined, PHP-FPM will fail to write to the log file if permissions are incorrect. The directory containing the log file must be owned by the user that PHP-FPM runs as, which is typically defined by the user and group directives in the same configuration file. Common users include www-data, apache, or nobody.

To fix permission issues, you can change the ownership of the log directory using the chown command. For example:

sudo chown www-data:www-data /var/log/php-fpm/
sudo chmod 755 /var/log/php-fpm/

After adjusting permissions, restart the PHP-FPM service to apply changes. On systemd-based systems, use sudo systemctl restart php-fpm or sudo systemctl restart php8.1-fpm. Always verify that the service started successfully without errors, as syntax mistakes in the configuration file can prevent the service from starting at all.

Testing and Debugging

Once the configuration is set and permissions are corrected, test the setup by triggering an error in your PHP script. A simple way to do this is to introduce a deliberate syntax error or call a non-existent function. Then, check the specified log file using the tail command:

tail -f /var/log/php-fpm/myapp-error.log

This real-time view allows you to see if errors are being captured correctly. If the log file remains empty despite errors occurring, double-check the error_log path in the pool configuration and ensure that the web server is indeed proxying requests to that specific pool. Misconfigurations in Nginx or Apache upstream definitions are a common cause of logs appearing in the wrong place.

For more advanced diagnostics, you can use the php-fpm -t command to test the syntax of your configuration files. This command returns a success message if the configuration is valid, or lists specific errors if there are typos or invalid directives. It is a quick sanity check before restarting the service.

Managing Logs Across Environments

In development environments, it is often helpful to set error_log = /dev/stderr so that logs appear in the terminal output when running PHP-FPM manually. This can speed up debugging significantly. However, in production, writing to a dedicated file is preferred for persistence and integration with log rotation tools.

Log rotation is essential to prevent disk space exhaustion. Configure logrotate to handle the specific log files defined in your PHP-FPM pools. Ensure that the rotation strategy includes compressing old logs and removing very old entries to maintain system health. Properly managed logs provide a clear audit trail and aid in rapid incident response.

Frequently Asked Questions

Where is the global PHP-FPM error log located?

The global error log is typically defined in the main php-fpm.conf file, not in the pool-specific configurations. Its path is controlled by the error_log directive at the top level of that file. This log captures startup errors and critical failures that occur before or outside of specific pool contexts.

Why are my PHP errors not showing up in the FPM log?

If errors are missing, check the php.ini settings for display_errors and log_errors. While log_errors controls whether errors are logged, display_errors controls their visibility on the screen. Additionally, ensure that the error_reporting level includes the types of errors you are trying to capture, as some levels may be suppressed by default.

Can I use syslog instead of a file for PHP-FPM logs?

Yes, you can set error_log = syslog in the pool configuration. This sends error messages to the system logger, which then writes them to standard syslog locations like /var/log/syslog or /var/log/messages. This approach integrates well with centralized logging systems but may require additional filtering to separate PHP errors from other system events.

How do I rotate logs for multiple PHP-FPM pools?

Create separate logrotate configuration files for each pool's log file. Define the path, rotation frequency, and compression settings in each file. This ensures that logs for different applications are managed independently, preventing one noisy application from affecting the log retention policies of others.

What happens if the log directory does not exist?

PHP-FPM will fail to start or will refuse to write logs if the specified directory does not exist or lacks write permissions. The service will likely report an error during startup or in the global error log. Always ensure that the directory exists and has the correct ownership before defining the path in the pool configuration.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More