【问题标题】:Fastcgi error - FastCgiIpcDir problems in error logFastcgi 错误 - 错误日志中的 FastCgiIpcDir 问题
【发布时间】:2012-03-02 16:11:47
【问题描述】:

错误日志中的 FastCgiIpcDir 问题

嗨,

我在我的 Apache 错误日志中注意到以下错误(错误 1):

[Wed Feb 08 14:00:06 2012] [alert] [client 41.185.88.175] (2)No such file or  directory: FastCGI: failed to connect to (dynamic) server "/var/www/bin/php-splashpage-user/php-fastcgi": something is seriously wrong, any chance the socket/named_pipe directory was removed?, see the FastCgiIpcDir directive

紧接着是这个错误(错误2):

[Wed Feb 08 14:00:06 2012] [error] [client 41.185.88.175] FastCGI: incomplete headers (0 bytes) received from server "/var/www/bin/php-splashpage-user/php-fastcgi"

如何修复错误 1?

我了解到由于主机系统定期清除“/tmp”目录(如果未定义,则为 fastCgiIpcDir 的默认目录)并因此消除与当前活动的 FastCGI 服务的通信而更改此设置。所以我决定试一试。我在 fastcgi.conf 文件中设置了 FastCgiIpcDir 以希望成功,但根本没有任何变化。

这是我的 fastcgi.conf 文件的内容:

<IfModule mod_fastcgi.c>
    FastCgiIpcDir /var/lib/apache2/fastcgi_test
    FastCgiConfig -idle-timeout 60 -maxClassProcesses 1
    FastCgiWrapper On

    AddHandler php5-fcgi .php
    Action php5-fcgi /cgi-bin/php-fastcgi

    <Location "/cgi-bin/php-fastcgi">
            Order Deny,Allow
            Deny from All
            Allow from env=REDIRECT_STATUS
            Options ExecCGI
            SetHandler fastcgi-script
    </Location>
</IfModule>

/var/lib/apache2/fastcgi_test 的权限和权限:

drwxr-xr-x  3 www-data www-data 4.0K 2012-02-08 09:20 fastcgi_test

我的 php 包装脚本 php_fastcgi 有以下几行:

#!/bin/sh

PHP_FCGI_CHILDREN=120
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=1000
export PHP_FCGI_MAX_REQUESTS

umask 0022
exec /usr/bin/php-cgi -d apc.shm_size=50

我正在运行 PHP 5.3.1、Apache/2.2.14、Ubuntu 10.04。

到目前为止,我总结了以下几点:

  • 错误 1 ​​仅出现在一个小时的开始,比如新小时后的 6 秒

通过使用 mod_FastCgi,我了解到增加子进程有助于缓解一些“错误 2”错误(这会导致随机间隔的 HTTP 500 错误)。目前我不太确定错误 1 ​​的影响是什么,但是如果错误 2 紧随其后,那么可以肯定地说这不是一件好事。

关于 Fastcgi 报告的错误的完整信息(如果有的话)的信息非常少,并提供了久经考验的解决方案。可悲的是,我可能只是在没有结论的情况下添加到网上发布的大量 Fastcgi 错误中。

您在解决错误 1 ​​方面的帮助、建议或技巧将不胜感激。

【问题讨论】:

    标签: apache2 fastcgi


    【解决方案1】:

    我不知道如何使它与包装器和 suexec 一起工作,但你应该试试这个:

    http://blog.kmp.or.at/2013/06/apache-2-2-on-debian-wheezy-w-php-fpm-fastcgi-apc-and-a-kind-of-suexec/

    链接中的解决方案甚至不使用 suexec,也不使用包装器,至少这样可以工作。

    所需的步骤:

    0) 安装 php5-fpm,如果还没有安装 apache-mpm-worker

    1) 评论这一行:

    #FastCgiWrapper On
    

    2) 制作别名:

    Alias /cgi-bin/php-fastcgi **/var/something**
    

    3) fastcgiexternalserver:

    FastCgiExternalServer **/var/something** -socket php5-fpm-site1user.sock
    

    (强类型路径必须相同)

    4) 在php5-fpm/pool.d/site1user.conf中设置conf

    [site1user]
    user = site1user
    group = site1user
    
    listen = /var/run/php5-fpm-site1user.sock
    
    pm = dynamic
    pm.max_children = 5
    pm.start_servers = 2
    pm.min_spare_servers = 1
    pm.max_spare_servers = 3
    
    chdir = /
    

    5) 重启 fpm 服务 php5-fpm 重启

    6)为了更深入地理解,请在此处查看我的其他答案

    https://serverfault.com/questions/524708/php5-fpm-apache2-on-wheezy-connect-failed-with-fastcgi/536277#536277

    【讨论】:

    • 出现错误时,“(2)No such file or directory”指的是什么文件/目录?
    • 知道了。 (2)No such file or directory 是因为我的PHP5-FPM 配置错误导致没有启动socket 文件导致的。我只是通过手动运行php5-fpmnot 使用该服务才发现错误。过去手动运行服务实际上也被证明可以很好地进行调试,因为有时使用sudo service ... start 不会提供任何反馈。
    猜你喜欢
    • 2014-08-23
    • 1970-01-01
    • 2011-12-07
    • 2019-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-16
    相关资源
    最近更新 更多