The error was encountered when adding new virtual server (new domain) to virtualmin. The server was running bot PHP as cgi and also as php-fpm.
However, while configuring the new domain, we got an error that php8-fpm could not restart.
Upon debugging, we got the error:
systemd: Stopping The PHP 8.1 FastCGI Process Manager... systemd: php8.1-fpm.service: Succeeded. systemd: Stopped The PHP 8.1 FastCGI Process Manager. systemd: Starting The PHP 8.1 FastCGI Process Manager... php-fpm8.1:  ALERT: [pool ] pm.min_spare_servers(1) and pm.max_spare_servers(25) cannot be greater than pm.max_children(20) php-fpm8.1:  ERROR: failed to post process the configuration php-fpm8.1:  ERROR: FPM initialization failed systemd: php8.1-fpm.service: Main process exited, code=exited, status=78/CONFIG systemd: php8.1-fpm.service: Failed with result 'exit-code'.
This error is because of, as it mentions, an issue with
pm.max_spare_servers settings. Somehow
max_spare_servers was being entered as greater number than the
max_children allowed in the configuration.
To fix this, we have to open the configuration file of this new server or domain that we just added and change the values of
max_children to be greater than
To edit it, goto (there will be a file with numbers in it, newly created):
The file would look something like this:
pm = dynamic pm.max_children = 20 pm.start_servers = 1 pm.min_spare_servers = 1 pm.max_spare_servers = 25
The files have the name of the server account on top, so make sure that you’re in the right file before changing it. Change the value of either
max_spare_servers to make max_children more than the spare servers. For example in the code block above, the
max_spare_servers is 25 which is greater than
max_children. Make it less than 20 to be safe.
Now restart the php-fpm (
php8.1-fpm) to use the new and updated file.
sudo service php8.1-fpm restart
Let me know if you’re still having the issue.