How PHP-FPM Works
A master process reads the configuration and starts worker processes. Each worker handles one request at a time, then waits for the next. The web server talks to the workers through the FastCGI protocol: Nginx with fastcgi_, Apache with mod_
Where the Files Are
| Item | Debian and Ubuntu | AlmaLinux and Rocky Linux |
|---|---|---|
| Service | php8. | php- |
| Pools | /etc/ | /etc/ |
| php.ini | /etc/ | /etc/ |
| Socket | /run/ | /run/ |
| Logs | /var/ | /var/ |
Replace 8.3 with your version (php -v): 8.3 on Ubuntu 24.04, 8.4 on Debian 13, and 8.5 on Ubuntu 26.04.
A Pool File
The default pool is www.conf. Its main lines on Debian and Ubuntu:
[www]
user = www-data
group = www-data
listen = /run/php/php8.3-fpm.sock
listen.owner = www-data
listen.group = www-data
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3For a second site, copy the file, change the name in brackets, the user, and the socket path, and point that site's web server configuration at the new socket. On AlmaLinux and Rocky Linux the pool runs as apache by default.
The Three pm Modes
- static: always runs
pm.max_workers. Predictable, and uses that memory all the time.children - dynamic: starts
pm.start_workers and keeps betweenservers pm.min_andspare_ servers pm.max_idle ones, up tospare_ servers pm.max_. A good default.children - ondemand: starts workers only when requests arrive and stops them after
pm.process_. Saves memory on quiet sites; the first request after a pause waits for a worker to start.idle_ timeout
pm.max_, for example 500, replaces each worker after that many requests, which contains slow memory leaks; the default, 0, never replaces them. The values above are the upstream defaults that Debian and Ubuntu keep; the AlmaLinux and Rocky Linux pool starts with higher numbers.
Sizing pm.max_children
The value is a memory budget. Measure the average size of a worker under normal traffic:
ps --no-headers -o rss -C php-fpm8.3 | awk '{s+=$1; n++} END {print s/n/1024 " MB"}'Use -C php-fpm on AlmaLinux and Rocky Linux. Then apply this rule of thumb: (memory for PHP) divided by (average worker size). On a 4 GB server, keep about 1 GB for the system and web server and 1 GB for the database. That leaves 2048 MB; at 50 MB per worker, 2048 / 50 is about 40, so set pm.max_. Set it too high and the server swaps or the OOM killer stops processes; too low, and requests queue. The log then warns that the pool reached pm.max_
Socket or TCP
- Unix socket:
listen = /run/php/php8.3-fpm.sock. For a web server on the same machine; access is controlled by the socket's owner and mode. - TCP:
listen = 127.0.0.1:9000. Needed when the web server runs elsewhere. Uselisten.allowed_and the firewall, and never expose the port to the internet.clients
Status Page and Slow Log
pm.status_path = /fpm-status
slowlog = /var/log/php8.3-fpm-slow.log
request_slowlog_timeout = 5sAllow the status path only from the server itself, for example with allow 127.0.0.1; and deny all; in its Nginx location. It shows active and idle processes, the listen queue, and how often the pool hit its maximum. The slow log records a stack trace of every request that runs longer than the timeout, which points at the slow code.
Test, Reload, Restart
sudo php-fpm8.3 -t
sudo systemctl reload php8.3-fpmOn AlmaLinux and Rocky Linux: sudo php-fpm -t and sudo systemctl reload php-fpm. Test first: a broken pool file keeps PHP-FPM from starting, and every PHP page fails. A reload makes the master process re-read its configuration and php.ini and replace the workers without stopping the service, so it is enough for pool and php.ini changes. With the default process_ in php-fpm.conf, workers are not given time to finish, so a long request can still be cut off; set it to a few seconds, for example 10s, if that matters. Keep a full restart for when a reload is not enough. Upload limits are in how to increase the PHP upload limit.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations