Two PHP-FPM pools: separate UIDs, Unix sockets and file rights
Create two PHP8.5-FPM pools and verify www-data FastCGI, worker identities, file permissions, actual Unix sockets and the reboot boundary.
Installing FPM does not decide which user executes each application. In a separate disposable Debian 13 VM running PHP 8.5.11, we manually created frontend and admin pools with distinct unprivileged users, Unix sockets, and var/cache and var/log directories.
Nginx does not forward requests to PHP yet; a FastCGI client connects directly as www-data.
Separate code ownership from mutable files
Root owns the code. Each pool reads its own required files and writes to its own mode-0700 var.
The web user can read public but cannot read the dummy private.txt. Frontend uses proof-web and admin uses proof-admin. Numeric UIDs/GIDs were allocated by this VM, rather than being portable constants.
An owned main file and pool configurations
The vendor configuration stays masked. Our main file is /etc/deploy-cli/php85/fpm.conf, with pool files under pools. Configuration belongs to root with mode 0600. This is the actual frontend pool:
[frontend]
user = proof-web
group = proof-web
listen = /run/deploy-cli-php85/frontend.sock
listen.owner = root
listen.group = www-data
listen.mode = 0660
pm = static
pm.max_children = 1
pm.max_requests = 0
chdir = /srv/php-fpm-demo/products/shop/frontend
clear_env = yes
catch_workers_output = yes
decorate_workers_output = no
process.dumpable = no
request_terminate_timeout = 0
security.limit_extensions = .php
ping.path = /__fpm_ping
ping.response = pong
php_admin_value[sys_temp_dir] = /srv/php-fpm-demo/products/shop/frontend/var/cache
php_admin_value[upload_tmp_dir] = /srv/php-fpm-demo/products/shop/frontend/var/cache
php_admin_value[session.save_path] = /srv/php-fpm-demo/products/shop/frontend/var/cache
php_admin_value[error_log] = /srv/php-fpm-demo/products/shop/frontend/var/log/php-error.log
Admin uses its own identity, socket and paths. The settings are documented in the PHP-FPM manual. One static worker per pool is our small verification profile, not production capacity guidance.
An owned minimal php.ini and PHP_INI_SCAN_DIR pointing to an empty directory also do not provide the full extension set for Symfony. Workers inherit the configuration already loaded by the master; the root-only file does not become writable by runtime users.
A separate systemd service
The service launches FPM in the foreground with explicit configuration paths. This is an excerpt; the complete unit also limits capabilities, system paths and memory, and includes separate cgroup BPF filtering for metadata addresses.
[Service]
Type=simple
Environment=PHP_INI_SCAN_DIR=/etc/deploy-cli/php85/scan
ExecStart=/usr/sbin/php-fpm8.5 --nodaemonize --force-stderr --fpm-config /etc/deploy-cli/php85/fpm.conf -c /etc/deploy-cli/php85/php.ini
Restart=no
KillSignal=SIGQUIT
SendSIGKILL=no
RuntimeDirectory=deploy-cli-php85
RuntimeDirectoryMode=0755
LogsDirectory=deploy-cli-php85
LogsDirectoryMode=0700
ProtectSystem=strict
NoNewPrivileges=yes
ReadWritePaths=/srv/php-fpm-demo/products/shop/frontend/var /srv/php-fpm-demo/products/shop/admin/var
The master log is under private /var/log/deploy-cli-php85. Our first /proc/self/fd/2 destination failed: FPM could not reopen systemd's logging socket and exited with status 78. We corrected this actual initialization failure before checking workers.
Active without usable workers
The next launch produced an active master, but its children failed at setuid. We stopped the service normally and used separate diagnostic launches. In this environment, explicit User=root and Group=root left CAP_SETUID in the bounding set while the master's effective set lost it. Using the default root context for a system service without those two lines retained the necessary permission, and both pools switched to their own UIDs.
This is an observed result for this unit and systemd environment, not a universal claim. We did not add CAP_SYS_PTRACE to the final service. Traced diagnostics were kept separate because ptrace changes the privilege-checking context and cannot substitute for the final ordinary launch.
Evidence from actual requests
Both sockets returned pong to www-data. A PHP fixture reported PHP_VERSION 8.5.11, SAPI fpm-fcgi, the owned php.ini and its worker PID. A root observer matched each PID to the master's children and checked its UID, GID, groups and cgroup.
| Check | Both pools |
|---|---|
| Worker | Own UID/GID and group, effective capabilities 0 |
| Socket | root:www-data, 0660; www-data connects successfully |
| Runtime user connects to the socket | EACCES |
| Own private.txt and cache write | Success with exact dummy bytes |
| Other pool's private read and cache write | Denied |
| Code write inside FPM | Read-only file system from the service sandbox |
| Code write by the same UID outside the sandbox | EACCES from filesystem permissions |
The positive file was created exclusively once. The screenshot captures the terminal running the first file probe, with its output labelled as a reduced summary. We did not repeat the write for a picture.
A separate reboot boundary
After a normal reboot, the service remained disabled/inactive, its PID and runtime directory were absent, and persistent configuration files matched exactly. Vendor services remained masked. A successful running-process check had not enabled startup.
A separate explicit start in the new boot confirmed both PHP responses and two Unix listeners. We matched socket inodes to master/worker FDs and kernel tables: those processes owned no inet sockets. We then stopped the service normally. Metadata probes and positive file writes were not repeated.

Configuration and controlled start through the CLI
After the manual stage, a separate clean VM completed four public CLI transactions: foundation, packages, configuration and activation. Each has plan/apply/verify. Configuration created its owned files and ran syntax checks while leaving FPM stopped. Only the following activation performed one explicit start; startup remained disabled.
Before starting, an ordinary ExecStartPre checks the root execution context, NoNewPrivileges and required capability set. This separate guard follows the manual setuid diagnosis. The privileged BPF helper only reads existing filters. After apply, the CLI uses a new isolated SSH connection; losing a result never triggers another start.
deploy-cli host fpm activation-verify \
--env-file "$ADMIN_ENV" --request-file "$ADMIN_REQUEST" \
--fpm-file "$FPM_PROFILE" --key-file "$REPOSITORY_KEYRING" \
--key-sha256 "$REPOSITORY_KEYRING_SHA256" \
--dependencies-file "$ACTIVATION_DEPENDENCIES" \
--plan-file "$ACTIVATION_PLAN" --plan-sha256 "$ACTIVATION_PLAN_SHA256"
The read-only invocation above uses the verified local build. Variables are private paths and approved hashes; the command contains no password. The screenshot shows reduced results from real activation-verify and current kernel readback, rather than raw JSON or a replay of the initial start.
status=passed
write_performed=false
startup=disabled
owned_unix_listeners=2
fpm_tcp_listeners=0
fastcgi_ping=200/pong (2)
