PHP-FPM (FastCGI Process Manager) is the recommended way to run PHP behind Nginx. It manages PHP worker processes efficiently, supports dynamic/static/ondemand process management, and provides per-pool configuration for multi-tenant servers. This guide configures PHP-FPM 8.4 with Nginx on Ubuntu 26.04 LTS.
Tested and valid on:
- Ubuntu 26.04 LTS
Prerequisites
- Ubuntu 26.04 LTS with Nginx installed
- PHP 8.4-FPM installed
- A user with sudo privileges
Step 1 – Install PHP-FPM
sudo apt install php8.4-fpm -y
sudo systemctl status php8.4-fpm
Step 2 – Configure the PHP-FPM Pool
The default pool is www.conf:
sudo nano /etc/php/8.4/fpm/pool.d/www.conf
Key settings to review:
[www]
user = www-data
group = www-data
listen = /run/php/php8.4-fpm.sock
pm = dynamic
pm.max_children = 25
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 10
Step 3 – Configure Nginx to Use PHP-FPM
In your Nginx server block, add:
location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/run/php/php8.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Step 4 – Test Configuration
sudo php-fpm8.4 -t
sudo nginx -t
Step 5 – Restart Both Services
sudo systemctl restart php8.4-fpm
sudo systemctl reload nginx
Step 6 – Create a Per-App Pool (optional)
For multi-site isolation, create a dedicated pool:
sudo cp /etc/php/8.4/fpm/pool.d/www.conf /etc/php/8.4/fpm/pool.d/myapp.conf
sudo nano /etc/php/8.4/fpm/pool.d/myapp.conf
Change the pool name, socket, and user:
[myapp]
user = myappuser
listen = /run/php/php8.4-myapp.sock
Step 7 – Monitor FPM Status
Enable the FPM status page in the pool config:
pm.status_path = /fpm-status
Add a restricted location in Nginx:
location /fpm-status { allow 127.0.0.1; deny all; fastcgi_pass unix:/run/php/php8.4-fpm.sock; include fastcgi_params; }
curl http://localhost/fpm-status
Conclusion
PHP-FPM 8.4 is now properly configured with Nginx on Ubuntu 26.04 LTS. Tune the process manager settings based on available RAM and expected concurrency for optimal performance.