PHP-FPM Multiple Pools on RHEL 9
Multiple pools allow different websites to run as different users, providing process isolation and security.
Pool directory
/etc/php-fpm.d/
Step 1 – Create a new pool for site1
Create /etc/php-fpm.d/site1.conf:
[site1]
user = site1
group = site1
listen = /run/php-fpm/site1.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 5
pm.max_requests = 200
; Logging
access.log = /var/log/php-fpm/site1-access.log
php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/php-fpm/site1-error.log
php_admin_flag[log_errors] = on
; Open basedir restriction
php_admin_value[open_basedir] = /var/www/site1:/tmp
Step 2 – Create system user
useradd -r -s /sbin/nologin site1
mkdir -p /var/www/site1/html
chown site1:site1 /var/www/site1/html
Step 3 – Reload PHP-FPM
systemctl reload php-fpm 2>/dev/null || rc-service php-fpm reload
Step 4 – Update Nginx/Apache to use new socket
In the Nginx server block for site1.example.com:
fastcgi_pass unix:/run/php-fpm/site1.sock;