0

我意识到这可能是一个重复的问题,但没有其他人帮助我(在寻找 4 天的解决方案之后)。

我正在将 nginx + php5-fpm 用于 Web 应用程序。它在 Apache 中完美运行,所以我知道这是一些配置问题。

我的网页按应有的方式加载 1-5 次,然后它们就是不加载,然后我每次都会收到 504 网关超时。

在我的慢日志中,我可以看到所有的PHP操作都成功了,最后一个函数也执行了。我不明白,这是因为php5-fpm吗?

慢日志:

[28-Jun-2014 12:45:33]  [pool www] pid 21245
script_filename = /home/XXX/public_html/feed.php
[0x00000000014a48f8] usleep() /home/XXX/cache.class.php:864
[0x00000000014a46c8] addLock() /home/XXX/cache.class.php:902
[0x00000000014a44e0] increment() /home/XXX/channel.class.php:124
[0x00000000014a4200] incrementWorkstamp() /home/XXX/channel.class.php:102
[0x00000000014a3f20] getWorkstamp() /home/XXX/channel.class.php:103
[0x00000000014a2908] getWorkstamp() /home/XXX/public_html/feed.php:162

现在我在慢日志中转储失败:

[28-Jun-2014 12:52:40]  [pool www] pid 29136
script_filename = /home/XXX/public_html/index.php
[0x00007fd7388d7620] session_start() /home/XXX/headers.php:2
[0x00007fd7388d7068] +++ dump failed

Web应用程序的nginx配置:

server {
    #listen   80; ## listen for ipv4; this line is default and implied
    #listen   [::]:80 default ipv6only=on; ## listen for ipv6

    root /home/XXX/public_html;
    index index.html index.htm index.php;

    # Make site accessible from http://localhost/
    server_name localhost;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to index.html
        try_files $uri $uri/ /index.php?$query_string;
        # Uncomment to enable naxsi on this location
        # include /etc/nginx/naxsi.rules
    }

    location /doc/ {
        alias /usr/share/doc/;
        autoindex on;
        allow 127.0.0.1;
        deny all;
    }

    # Only for nginx-naxsi : process denied requests
    #location /RequestDenied {
        # For example, return an error code
        #return 418;
    #}

    #error_page 404 /404.html;

    # redirect server error pages to the static page /50x.html
    #
    #error_page 500 502 503 504 /50x.html;
    #location = /50x.html {
    #   root /usr/share/nginx/www;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

        # With php5-cgi alone:
        fastcgi_pass 127.0.0.1:9000;
        # With php5-fpm:
        fastcgi_index index.php;
        include fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny all;
    }

    error_page 500 /errors/6.php;
    error_page 404 /errors/4.php;
    error_page 403 /errors/2.php;

    if (!-e $request_filename){
        rewrite ^/user\/([^/]+)\/?([a-zA-Z]*)? /profile.php?username=$1&tab=$2 last;
    }
    if (!-e $request_filename){
        rewrite ^/messages\/([^/]+)\/? /messages.php?chat=$1 last;
    }
    if (!-e $request_filename){
        rewrite ^/interests\/([^/]+)\/? /interests.php?interest=$1 last;
    }

    if (!-e $request_filename){
        rewrite ^/(.*?)/?$ /$1.php last;
    }
}

更新: session_start() 可以是罪魁祸首吗?我认为它挂在开始?

4

1 回答 1

0

解决了。显然,是函数 getWorkstamp() 导致问题,带有无限循环。

于 2014-06-30T07:54:39.933 回答