There are many possible reasons why your PHP-FPM would reach the max_children
. Most common ones are:
- A lot of parallel requests from your clients
- Slow execution of the PHP scripts
- Very low setting of the
max_children
Looking at the specs of your machine, assuming there is nothing else than PHP+Nginx running, I think you could set it much higher than 5. You say you have 8 Cores, usually Nginx needs much less CPU than PHP, so with 5 children you will probably never be able to use all of them. I'm usually setting it to something like the number of cores x 2 or number of cores x 4, depending on the memory consumption of your PHP scripts.
PHP is running inside the chroot jail. So once you set this:
chroot = /opt/jail/example/home/example
Then the path /opt/jail/example/home/example
becomes the path /
for PHP. Because of that this is non-sensical:
php_admin_value[open_basedir]=/opt/jail/example/home/example
as PHP no longer has access to /opt/jail/example.... because it's outside of the root path.
You haven't posted it but you also need to make a change to the fastcgi_param config file, where you set the SCRIPT_FILENAME
parameter which probably looks like this:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
which needs to be changed to something like:
fastcgi_param SCRIPT_FILENAME webroot/$fastcgi_script_name;
where if you combine the values of chroot
+ webroot
+ $fastcgi_script_name
you get the absolute path of the file on the disk. Because PHP is running in the chroot you don't need to include it in the path.
btw It's a better practice to have the chroot to be set to one level above the webroot, so that your application can write to log files that are within the chroot, but not in the webroot, so that there's no way for them to be accidentally downloaded by a user.
So your directories would be:
/opt/jail/example/home/ <-- chroot
/opt/jail/example/home/example <-- Read only directory is exposed as webroot (or document root).
/opt/jail/example/home/var/log <-- Writeable directory that holds log files.
Best Answer
If you just want to know how many workers are currently running, you can try with HTOP, do a htop and filter (F4) with "php-fpm".
Or with ps
If you want precise and technical informations, you can use the fpm status page:
Add this to you pool configuration:
Then this in your nginx configuration: (adapt to your configuration)
You can then use CURL to query with:
Which gives you something like:
More informations / Source: https://easyengine.io/tutorials/php/fpm-status-page