簡體   English   中英

504網關超時nginx + php5-fpm

[英]504 gateway timeout nginx+php5-fpm

我意識到這可能是一個重復的問題,但是沒有其他人幫助我(解決方案搜索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()是罪魁禍首嗎? 我認為它掛起了嗎?

解決了。 顯然,這是函數getWorkstamp()導致問題的原因,並帶有無限循環。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM