Skip to content

How to enable request_slowlog_timeout on cPanel PHP-FPM

Turn on the PHP-FPM slow log for one cPanel domain or the whole server by setting request_slowlog_timeout in the YAML files cPanel builds its pools from, so the change survives every rebuild. You then prove it captures slow requests with a test script and keep the log from filling the disk.

When a WordPress site on your cPanel server slows down at random and nobody can reproduce it, the PHP-FPM slow log shows you where the time goes. PHP-FPM is the service that runs PHP for each site, and once a request passes a threshold you choose, it writes down the PHP function the request was stuck in. On cPanel there is a catch. The pool files PHP-FPM reads are generated, so a line you add by hand disappears the next time cPanel rebuilds them. Put the two settings, request_slowlog_timeout and slowlog, in the domain’s YAML file instead, rebuild, and confirm the result with a deliberately slow test page.

What you’ll accomplish

  • Find the YAML file that controls one domain’s PHP-FPM pool, and the generated file you should leave alone.
  • Turn on the slow log for that domain with a 5-second threshold, in a way that survives cPanel rebuilds and updates.
  • Prove it works with a test script that sleeps past the threshold.
  • Keep the log from growing without limit, and switch it off cleanly when you are done.
  • Optionally apply the same setting to every domain on the server.

Prerequisites

  • Root SSH access to a cPanel and WHM server running EasyApache 4.
  • The domain must use PHP-FPM. In WHM » Software » MultiPHP Manager, the domain’s row shows PHP-FPM switched on. LiteSpeed servers that use LSAPI do not run PHP-FPM, so nothing here applies to them.
  • The domain’s PHP version. The examples use ea-php82, user exampleuser and domain example.com. Swap in your own values everywhere.
  • A quiet moment for one restart. Restarting a PHP version’s service briefly interrupts requests in flight for every site on that version.

How it works

PHP-FPM (short for FastCGI Process Manager) gives each domain its own pool, a set of worker processes that only serve that site. A master process, running as root, hands requests to those workers and keeps an eye on them.

Two pool settings switch the slow log on. request_slowlog_timeout is the threshold, for example 5s. slowlog is the file the traces go to. Both are needed. PHP-FPM refuses to start if you set the threshold without a log file.

The master does not watch every request continuously. It checks on a timer that fires about every third of the threshold, so with 5s it looks roughly every 1.7 seconds. When it finds a worker busy past the threshold, it pauses that worker for a moment. It does this with ptrace, a Linux feature that lets one process look inside another. The master reads the worker’s PHP call stack and appends that backtrace to the slow log. A backtrace is the chain of function calls that led to the current line, with file names and line numbers. The request then carries on. The slow log only records it, never kills it.

On cPanel you never write these settings into the pool file directly. cPanel builds each pool file from YAML files, as the diagram shows.

Where the PHP-FPM slow log setting lives on cPanel: a server-wide YAML default and a per-domain YAML file feed php_fpm_config --rebuild, which writes the generated pool file you must not edit, then PHP-FPM restarts and writes the slow log

  • /var/cpanel/userdata/<user>/<domain>.php-fpm.yaml holds one domain’s pool settings. Values here override the server-wide defaults.
  • /var/cpanel/ApachePHPFPM/system_pool_defaults.yaml holds defaults for every pool. It does not exist until you create it.
  • /opt/cpanel/ea-php82/root/etc/php-fpm.d/<domain>.conf is the generated pool file. cPanel’s documentation says plainly not to edit it, because a rebuild rewrites it.

In the YAML files, key names replace dots and brackets with underscores. Our two keys already use underscores, so they keep their usual names.

Step-by-step

  1. Confirm the domain runs on PHP-FPM and find its version. Look for the generated pool file for the domain:
ls -d /opt/cpanel/ea-php*/root/etc/php-fpm.d/example.com.conf

Example output:

/opt/cpanel/ea-php82/root/etc/php-fpm.d/example.com.conf

The ea-php82 part of the path is the PHP version serving the domain. If ls reports “No such file or directory”, the domain is not on PHP-FPM. Turn PHP-FPM on in MultiPHP Manager first, or see “When this is the wrong approach” below.

  1. Find and back up the domain’s YAML file. cPanel names it <domain>.php-fpm.yaml and keeps it in the account’s userdata folder. List the folder first to confirm the exact name:
ls /var/cpanel/userdata/exampleuser/ | grep -i fpm
cp -a /var/cpanel/userdata/exampleuser/example.com.php-fpm.yaml /root/example.com.php-fpm.yaml.bak
cat /var/cpanel/userdata/exampleuser/example.com.php-fpm.yaml

Example output:

example.com.php-fpm.yaml
---
_is_present: 1
pm_max_children: 8
pm_max_requests: 40

The file starts with --- and lists only the values that differ from the defaults. Yours may hold different keys, or only _is_present: 1. If ls prints nothing, the domain has no PHP-FPM YAML file yet, which means PHP-FPM is not on for it. Go back to step 1. Keep the backup in /root, not next to the original, so cPanel never mistakes it for a live file.

  1. Create a root-only folder for the logs. The traces show file paths from inside the site, and the master writes them as root. Keeping them out of the user’s home folder means no account can read them or redirect where root writes.
mkdir -p /var/log/php-fpm-slow
chmod 700 /var/log/php-fpm-slow
ls -ld /var/log/php-fpm-slow

Example output:

drwx------ 2 root root 4096 Oct  7 09:12 /var/log/php-fpm-slow

You do not need to create the log file itself. PHP-FPM creates it when it starts.

  1. Add the two settings to the domain’s YAML file. Append them at the end, keeping the existing --- line at the top:
cat >> /var/cpanel/userdata/exampleuser/example.com.php-fpm.yaml <<'EOF'
request_slowlog_timeout: 5s
slowlog: /var/log/php-fpm-slow/example_com.slow.log
EOF
tail -n 2 /var/cpanel/userdata/exampleuser/example.com.php-fpm.yaml

Example output:

request_slowlog_timeout: 5s
slowlog: /var/log/php-fpm-slow/example_com.slow.log

PHP-FPM reads 5s as five seconds. A bare 5 means the same thing, so use it if your setup prefers plain numbers. Check the indentation. Each key must start at the beginning of the line, like the keys above it. cPanel’s docs warn that a YAML syntax error can stop PHP-FPM from starting, which is why you made the backup.

  1. Rebuild the pool file for this domain. The --domain option limits the rebuild to one site:
/usr/local/cpanel/scripts/php_fpm_config --rebuild --domain=example.com; echo "exit=$?"

Example output:

exit=0

Any exit code other than 0 means the rebuild failed. Run /usr/local/cpanel/scripts/php_fpm_config --check to see what it complains about, and compare your YAML with the backup.

  1. Check that the generated pool file picked up the settings.
grep -E 'slowlog' /opt/cpanel/ea-php82/root/etc/php-fpm.d/example.com.conf

Example output:

request_slowlog_timeout = 5s
slowlog = /var/log/php-fpm-slow/example_com.slow.log

Spacing and line order may differ slightly. If the command prints nothing, the rebuild did not read your YAML. Check the file name from step 2 and run the rebuild again.

  1. Test the configuration, then restart that PHP version. The rebuild may already reload PHP-FPM, but an explicit restart removes any doubt. Test first, so a mistake cannot take the service down:
/opt/cpanel/ea-php82/root/usr/sbin/php-fpm -t --fpm-config /opt/cpanel/ea-php82/root/etc/php-fpm.conf
systemctl restart ea-php82-php-fpm
systemctl is-active ea-php82-php-fpm

Example output:

[07-Oct-2026 09:14:52] NOTICE: configuration file /opt/cpanel/ea-php82/root/etc/php-fpm.conf test is successful
active

If the test prints an ERROR line instead, do not restart. The usual messages are covered under Troubleshooting.

Choosing the threshold

Start at 5s for a public WordPress site. A healthy page should finish well under that, so anything caught is worth reading. After a day, adjust with a simple rule. If the log gains more than about 50 traces an hour, raise it to 10s, because you are catching routine slowness and the noise hides the real problem. If it stays empty while visitors still report slow pages, lower it to 3s. Avoid going below 2s on a busy site, since every trace briefly pauses a worker.

If the pool also sets request_terminate_timeout, the time limit after which FPM kills a request, the slow log threshold cannot be higher than that limit. PHP-FPM refuses to start otherwise.

Turning it on for every domain

Once the setting proves useful, you can make it the server-wide default. Create or extend /var/cpanel/ApachePHPFPM/system_pool_defaults.yaml. The second line below writes the --- header only when the file is new or empty, so an existing file keeps a single header:

mkdir -p /var/cpanel/ApachePHPFPM
[ -s /var/cpanel/ApachePHPFPM/system_pool_defaults.yaml ] || echo '---' > /var/cpanel/ApachePHPFPM/system_pool_defaults.yaml
cat >> /var/cpanel/ApachePHPFPM/system_pool_defaults.yaml <<'EOF'
request_slowlog_timeout: 5s
slowlog: '/var/log/php-fpm-slow/[% scrubbed_domain %].slow.log'
EOF
/usr/local/cpanel/scripts/php_fpm_config --rebuild; echo "exit=$?"

[% scrubbed_domain %] is a cPanel template value. It becomes the domain name with dots turned into underscores, so each site gets its own file. Two limits apply. A value in a domain’s own YAML file still wins. And cPanel’s docs note that once you edit a domain’s pool in MultiPHP Manager, that domain stops taking the system defaults. Run the grep from step 6 on two or three domains to see what each one actually received.

Validate it works

Create a test page that sleeps for 12 seconds, a little over twice the threshold. The extra margin matters because the master only checks on its timer.

cat > /home/exampleuser/public_html/slowtest.php <<'EOF'
<?php
sleep(12);
echo "done\n";
EOF
chown exampleuser:exampleuser /home/exampleuser/public_html/slowtest.php
curl -s -o /dev/null -w '%{http_code} %{time_total}\n' https://example.com/slowtest.php

Example output:

200 12.084311

Now read the slow log:

tail -n 4 /var/log/php-fpm-slow/example_com.slow.log

Example output:


[07-Oct-2026 09:18:43]  [pool example_com] pid 731905
script_filename = /home/exampleuser/public_html/slowtest.php
[0x00007f9c3e813f40] sleep() /home/exampleuser/public_html/slowtest.php:2

That entry is the proof. It names the pool, the script and the exact line where the request was waiting. The master also logs a warning in the PHP version’s error log:

grep 'executing too slow' /opt/cpanel/ea-php82/root/usr/var/log/php-fpm/error.log | tail -n 1

Example output:

[07-Oct-2026 09:18:43] WARNING: [pool example_com] child 731905, script '/home/exampleuser/public_html/slowtest.php' (request: "GET /slowtest.php") executing too slow (5.483120 sec), logging

Delete the test page when you are done, so nobody can use it to tie up workers:

rm -f /home/exampleuser/public_html/slowtest.php

To make sense of real traces, such as a stack ending in mysqli_query() or curl_exec(), follow reading the PHP-FPM slow log on cPanel. In brief, the top frame shows what the request was waiting on at that moment.

Keep the log from filling the disk

Each trace is only a few lines, but a busy site with a slow plugin can write thousands a day. Add a logrotate rule:

cat > /etc/logrotate.d/php-fpm-slow <<'EOF'
/var/log/php-fpm-slow/*.log {
    weekly
    rotate 4
    compress
    missingok
    notifempty
}
EOF
logrotate -d /etc/logrotate.d/php-fpm-slow 2>&1 | grep -E 'considering log|error'

Example output:

considering log /var/log/php-fpm-slow/example_com.slow.log

The -d flag is a dry run that only prints what logrotate would do. You want one considering log line per slow log file and no line containing error. An error usually points to a typo in the rule, so compare it with the block above. No reload is needed after rotation, because PHP-FPM opens the slow log fresh for every trace.

Turning it off

Remove the two lines from the domain’s YAML file, rebuild, restart, and check that the grep from step 6 now prints nothing:

sed -i '/^request_slowlog_timeout:/d; /^slowlog:/d' /var/cpanel/userdata/exampleuser/example.com.php-fpm.yaml
/usr/local/cpanel/scripts/php_fpm_config --rebuild --domain=example.com; echo "exit=$?"
systemctl restart ea-php82-php-fpm
grep -E 'slowlog' /opt/cpanel/ea-php82/root/etc/php-fpm.d/example.com.conf

You should see exit=0 and nothing after it. If the grep still prints the two lines, the rebuild did not run cleanly, so repeat step 5. The old log file stays on disk until you delete it.

Troubleshooting

  • The settings vanished from the pool file. Someone hand-edited the .conf file and a rebuild replaced it, or the keys were never in the YAML. Put them in the YAML file, then rebuild. After any later save in MultiPHP Manager’s PHP-FPM settings for that domain, run the step 6 grep again to make sure your two keys are still there.
  • PHP-FPM will not start after the change. Run the test from step 7 and read the ERROR line. 'slowlog' must be specified for use with 'request_slowlog_timeout' means the slowlog key is missing or misspelled. 'request_slowlog_timeout' (5) can't be greater than 'request_terminate_timeout' means you need a lower threshold or a higher terminate limit. A YAML parse error in php_fpm_config --check usually means bad indentation. Restore your backup if in doubt.
  • Unable to create or open slowlog(...) appears in the step 7 test or the error log. The folder in the path does not exist, or root cannot write to it. Create it as in step 3, then test again before you restart.
  • The “executing too slow” warning appears but the slow log stays empty. Look for failed to ptrace(ATTACH) child in the same error log. That message means the kernel refused the ptrace call the master uses to read the worker’s stack. Some containers and hardened kernels block it. Check sysctl kernel.yama.ptrace_scope. A value of 3 blocks ptrace entirely, and it cannot be lowered again until the next reboot. On a container, ask the platform whether the CAP_SYS_PTRACE capability can be granted.
  • No warning and no trace at all. The request may not have reached PHP-FPM. Check that the test page returned after about 12 seconds, that you edited the right PHP version’s paths, and that a cache or CDN did not answer instead. A test page ending in .php is rarely cached, but some setups cache everything.

When this is the wrong approach

  • The server uses LiteSpeed with LSAPI. There is no PHP-FPM pool, so these settings do nothing. Profile at the application level instead.
  • Requests wait in a queue rather than run slowly. When every worker is busy, new requests wait before PHP even starts. The slow log never sees that wait. Check the pool size with calculating pm.max_children on a shared cPanel server.
  • The slow work runs outside a web request. WP-CLI commands and system cron jobs run through the PHP command line, not PHP-FPM, so they never appear here.
  • You need timing for every request, not only the slow ones. The slow log samples outliers. For averages and percentiles, use your web server’s access log with a response time field, or an application performance tool.

For every pool option and its default, see cPanel’s configuration values of PHP-FPM and the PHP manual’s FPM configuration reference.

If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.