spawn-fcgi / fast CGi php在Gentoo上的日志中无痕迹地崩溃

我最近从apache移动到Nginx / fastcgi解决scheme,我运行在Fedora系统上,没有任何问题,但是,因为我把所有的东西都搬到了Gentoo上,Spawn-fCGI / fastcgi php守护进程死了,我找不到在/ var / log / messages中输出任何错误报告,所以我不知道为什么会发生这种情况。

我已经看到fastcgi与fedora发行版有所不同,因为它有不同的conf文件和init.d启动脚本,有人可以帮助我使它更稳定吗? 请求的数量与我在Fedora上的请求数量没有任何区别,所以我使用了发行版随附的默认configuration。在大约几个小时内,它就会死亡。

非常感谢你

这是我的/etc/conf.d/php-cgi文件的内容(它是原始spawn-fcgi conf.d文件的修改后的副本):

 # The FCGI process can be made available through a filesystem socket or # through a inet socket. One and only one of the two types must be choosen. # Default is the inet socket. # The filename specified by # FCGI_SOCKET will be suffixed with a number for each child process, for # example, fcgi.socket-1. # Leave empty to use an IP socket (default). See below. Enabling this, # disables the IP socket. # FCGI_SOCKET= # When using FCGI_PORT, connections will only be accepted from the following # address. The default is 127.0.0.1. Use 0.0.0.0 to bind to all addresses. # FCGI_ADDRESS=127.0.0.1 # The port specified by FCGI_PORT is the port used # by the first child process. If this is set to 1234 then subsequent child # processes will use 1235, 1236, etc. # FCGI_PORT=2000 # The path to your FastCGI application. These sometimes carry the .fcgi # extension but not always. For PHP, you should usually point this to # /usr/bin/php-cgi. # FCGI_PROGRAM=/usr/bin/php-cgi #FCGI_PROGRAM=/usr/bin/spawn-fcgi # The number of child processes to spawn. The default is 1. # FCGI_CHILDREN=1 # If you want to run your application inside a chroot then specify the # directory here. Leave this blank otherwise. # FCGI_CHROOT= # If you want to run your application from a specific directiory specify # it here. Leave this blank otherwise. # FCGI_CHDIR= # The user and group to run your application as. If you do not specify these, # the application will be run as root:root. # FCGI_USER=nginx FCGI_GROUP=nginx # Additional options you might want to pass to spawn-fcgi # #FCGI_EXTRA_OPTIONS= # If your application requires additional environment variables, you may # specify them here. See PHP example below. # #ALLOWED_ENV="PATH" # PHP ONLY :: These two options are specific to PHP. The first is the number # of child processes to spawn. The second is the number of requests to be # served by a single PHP process before it is restarted. # PHP_FCGI_CHILDREN=5 PHP_FCGI_MAX_REQUESTS=500 # # For this to work you would set ALLOWED_ENV="PATH PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS" 

然后为了创buildinit.d文件,只需要使用你的conf.d文件(在我的例子中是php-cgi)的名字来创build一个符号链接到原始的spawn-fcgi init.d文件中:

 % sudo ln -s /etc/init.d/spawn-fcgi /etc/init.d/php-cgi 

然后你可以开始它:

 % /etc/init.d/php-cgi start 

并将其添加到默认的引导级别

 % rc-update add php-cgi default 

你拥有的唯一的自由度是通过调整这两个值:

 PHP_FCGI_CHILDREN=5 PHP_FCGI_MAX_REQUESTS=500 

更多的孩子可以同时处理更多的请求,但是会消耗更多的内存。
根据您的硬件configuration,调整这两个设置。

在这里得到了完全相同的问题…通过在交互模式下运行spawn-fcgi(所以它不叉)在一个无限的while循环中包装(以便重新启动)。

我也遇到了同样的问题

我遇到两个解决scheme:

  • cron的fastcgi重启:“0 * * * * /etc/init.d/fastcgi restart”。 这是丑陋的,但它的工作
  • 这个问题似乎来自php-cgi进程,长时间后变得不稳定。 这是可以修复的,迫使php-cgi在最大数量的请求之后通过envvariables来更新进程:“export PHP_FCGI_MAX_REQUESTS = 500”