PHP-FPM and OPcache: checking a pool’s effective settings
Inspect live PHP-FPM pools: working directory, session path, extensions and OPcache, and trace why a diagnostic script rejected a ready service.
PHP-FPM started, its two workers had the correct UIDs and GIDs, extensions loaded, and OPcache was running. Our CLI nevertheless refused to mark activation complete. The diagnostic script was the cause: its expectations about the working directory and reading the session path did not match PHP's observed behavior.
This check used a separate disposable Debian 13 VM with PHP 8.5. Two pools ran under one FPM master. This article covers observation of their state; application integration and acceptance after reboot have their own steps.
Starting a service does not finish verification
Before starting FPM, the CLI stored an incomplete journal, dispatched start once, and proceeded to read processes, sockets and worker responses. The journal retained the following fields after refusal. This is a reduced actual record with nested private approvals omitted:
{
"phase": "pending",
"completed": ["start"],
"step": "runtime"
}
A separate systemd read showed active/running. FPM logged ready to handle connections. The master ran as root and the workers as different service users, with zero effective and permitted capabilities. We therefore needed to identify why observation of the already running processes had failed.
The pool's chdir and the executing script directory
Each pool configuration specified its own chdir. The diagnostic PHP file, however, lived in a shared protected directory outside public: /usr/local/lib/deploy-cli-php85. While executing that file, getcwd() returned the script directory. Comparing its hash with the application root was an incorrect expectation in our observer.
The response still contains a working-directory hash. The verifier now compares it with the directory of this particular diagnostic file. Actual UID, GID, the pool socket and its own session path identify the pool; getcwd() alone is insufficient.
'cwd_sha256' => hash('sha256', getcwd()),
Why ini_get returned the other path's hash
The second finding was less obvious. The two pool configurations had different session.save_path values. Initially, the shared script read the setting as follows:
'session_path_sha256' => hash('sha256', ini_get('session.save_path')),
After the first request through admin, a request through frontend returned the same admin path hash. Its UID and GID still belonged to the correct worker. This did not establish which directory the session engine actually used.
The behavior is consistent with a verified upstream PHP issue: the optimizer can retain a literal ini_get() result for a directive fixed through PHP_ADMIN_VALUE in shared cached code. Our fixture observation and the upstream explanation are separate evidence sources; we did not collect an opcode dump for this case.
Reading the current session engine state
We changed this field to use session_save_path() without arguments. That call returns the current path; changing it requires passing the corresponding argument. The behavior is described in the session_save_path documentation.
'session_path_sha256' => hash('sha256', session_save_path()),
We placed the candidate observer in a separate new file on the training VM, preserving the previous file and journal. Four reads used real FastCGI sockets: admin, frontend, frontend, admin. The following is the actual reduced result; full responses also contained worker identity, extensions, INI values and path hashes:
[
{"pool":"s200admin","session_engine_path_correct":true,"opcache_running":true},
{"pool":"s200front","session_engine_path_correct":true,"opcache_running":true},
{"pool":"s200front","session_engine_path_correct":true,"opcache_running":true},
{"pool":"s200admin","session_engine_path_correct":true,"opcache_running":true}
]
Each pool returned the hash of its own session directory. OPcache remained enabled. The script did not call session_start(), create session files or change pool settings. Private paths and environment variables were not returned.
Handling the incomplete activation
Successful diagnostic reads did not rewrite the old journal as committed. Start had already happened, while the complete operation had not produced an approved result; we did not repeat apply against that state. We corrected the source, checked local contracts and prepared a new clean run for complete CLI acceptance.
The new run completed PHP verification
After the correction, another clean VM executed the complete activation-apply and activation-verify through the CLI. Both passed; the second used a separate SSH connection and confirmed the same manifest. These are grouped fields from the two actual receipts:
{
"apply": {
"status": "passed",
"action": "activation-apply",
"write_performed": true,
"write_state": "changed"
},
"verify": {
"status": "passed",
"action": "activation-verify",
"write_performed": false,
"write_state": "none"
}
}
This result covers starting and verifying the two PHP pools. Session and log maintenance, HTTP through Nginx and data services each have separate operations.
This case shows the practical value of separate readiness verification: active in systemd, correct processes and a PHP response establish different facts. The observer itself also needs checks against real workers sharing OPcache. An assumption about one function's return value should not replace observing the mechanism being verified.
