Baota Installation: PHP 7.2 and PHP 8.1 PHP-FPM Restart Issue

@高效码农  June 24, 2024

Problem Description
I installed PHP 7.2 and PHP 8.1 using BaoTa. Recently, I noticed that the server content has been gradually increasing. Upon checking the processes, I discovered that PHP-FPM 8.1 restarts every 10 minutes, errors out during the restart, and then initiates two new PHP-FPM 8.1 processes while killing one of the previously started processes. This causes the number of processes to continually increase, along with the number of child processes, eventually filling up the memory.

Error messages encountered:

vbnet

ERROR: Another FPM instance seems to already listen on /tmp/php-cgi-81.sock
ERROR: FPM initialization failed

Troubleshooting Attempts
Most solutions found online suggest deleting /tmp/php-cgi-81.sock and restarting the PHP-FPM process. However, this method did not work in my case. Upgrading PHP versions and reinstalling PHP also did not resolve the issue.

Solution
Here is the solution I found, though I am unsure of its general applicability. I hope it might be helpful to others.

In the directory /www/server/panel/vhost/nginx, locate the phpfpm_status.conf configuration file and add the following code:

nginx

location /phpfpm_81_status {
    fastcgi_pass unix:/tmp/php-cgi-81.sock;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
}

This solved the problem, but the reason for the issue remains unknown. I do not understand why PHP-FPM restarts every 10 minutes, nor why adding this configuration resolves the issue. I compared both the testing and development environments, which do not have this configuration but do not exhibit the same problem. If anyone knows the cause, please enlighten me.



添加新评论