服务器在php5-fcgid.confconfiguration后每10分钟停止一次响应,为什么?

我安装了PHP5-CGI,安装了Apache和MYSQL。 在添加这些设置之前,PHP5-CGI会无休止地拥有> 15个进程,每个进程占用5MB的内存。 所以我将这些设置添加到/etc/apache2/conf.d/php5-fcgid.conf,并且PHP5-cgi进程是有限的。 然而,现在每次我打开4或5分钟就说20个线程/页面,服务器停止正常运行,事情冻结,页面停止加载,直到2或3分钟过去,然后再次快速闪烁。

AddHandler fcgid-script .fcgi .php # Where to look for the php.ini file? DefaultInitEnv PHPRC "/etc/php5/cgi" # Where is the PHP executable FCGIWrapper /usr/bin/php-cgi .php # Maximum requests a process handles before it is terminated MaxRequestsPerProcess 1500 # Maximum number of PHP processes. MaxProcessCount 15 # Number of seconds of idle time before a process is terminated IPCCommTimeout 240 IdleTimeout 240 # Large site ServerLimit 2048 ThreadLimit 100 StartServers 10 MinSpareThreads 30 MaxSpareThreads 100 ThreadsPerChild 64 MaxClients 2048 MaxRequestsPerChild 5000 

我正在运行一个网站(SMF论坛),平均每20分钟约450个用户,所以它有点忙碌。 发生什么了?

我看到的第一件事就是你的FCGIWrapper看起来像实际的php-cgi可执行文件,而不是一个包装脚本,用来configurationPHP期望的环境variables,这些variables值将与fcgid工作。 默认情况下,PHP在500次请求后退出,但你有fcgid期望它们持续1500次。你可以在Apache的文档中find例子和解释,但基本上你需要设置PHP_FCGI_MAX_REQUESTS环境variables大于MaxRequestsPerProcess设置fcgid正在使用。

您可以跳过包装脚本,只需在Apacheconfiguration文件中使用DefaultInitEnv PHP_FCGI_MAX_REQUESTS 1501

此外,你的configuration是旧的,所有的指令名称已经改变,但旧的是现在可用。