【问题标题】:Magento place order / checkout time out - 502 Bad GatewayMagento 下订单/结帐超时 - 502 Bad Gateway
【发布时间】:2017-04-03 23:20:46
【问题描述】:

我尝试在 Magento 下订单时遇到 502 错误,我还尝试禁用可下载产品和 RSS 提要。

我收到了订单确认电子邮件,库存已更新,在管理面板中我可以正确查看订单,但我在结帐/onepage/success/ 处没有收到成功消息,而是收到由 a 引起的 502 错误超时。

我得到的唯一错误消息是 os nginx 日志:

2013/12/21 18:49:47 [error] 18449#0: *191 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 177.103.69.141, server: dev.canalagricola.com.br, request: "GET /checkout/onepage/success/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "dev.canalagricola.com.br", referrer: "http://dev.canalagricola.com.br/checkout/onepage/"

我在一个小型实例(PHP5.5、PHPFPM-5.5、Nginx 1.4.3、Mysql 5.5、Magento 1.8.1)上使用 Amazon Linux(64 位)

magento.conf (nginx)

server {
    listen          80;
    server_name     dev.canalagricola.com.br;

    access_log      off;

    root            /var/www/canalagricola;
    index           index.php;

    gzip            on;
    gzip_min_length 10240;
    gzip_comp_level 9;
    gzip_proxied    expired no-cache no-store private auth;
    gzip_types      text/plain text/css text/xml text/javascript application/x-javascript application/xml application/xml+rss;
    gzip_disable    "MSIE [1-6]\.";

    sendfile        on;
    tcp_nodelay     on;
    tcp_nopush      on;

    keepalive_timeout       30;
    keepalive_requests      100000;
    reset_timedout_connection on;
    client_body_timeout     10;
    send_timeout            2;

    location / {
            try_files $uri $uri/ @handler;
            expires 30d;
    }

    location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
            log_not_found     off;
            expires           1y;
    }

    location ^~ /(app|includes|lib|media/downloadable|pkginfo|report/config.xml|var)/ { internal; }

    location /var/export/ { internal; }

    location /. { return 404; }

    location @handler { rewrite / /index.php; }

    location ~* .php/ { rewrite ^(.*.php)/ $1 last; }

    location ~* .php$ {
            if (!-e $request_filename) { rewrite / /index.php last; }
            expires off;
            fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  SCRIPT_NAME      $fastcgi_script_name;
            fastcgi_param  MAGE_RUN_CODE    default;
            fastcgi_param  MAGE_RUN_TYPE    store;
            fastcgi_read_timeout            300;
            include fastcgi_params;
    }

    rewrite ^/minify/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
    rewrite ^/skin/m/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;

    location /lib/minify/ {
            allow all;
    }
}

www.conf (php-fpm)

[www]

listen = /var/run/php-fpm/php-fpm.sock
listen.allowed_clients = 127.0.0.1
listen.owner = nginx
listen.group = nginx
listen.mode = 0664
user = nginx
group = nginx

pm = dynamic
pm.max_children = 4
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 200
request_terminate_timeout = 300s
rlimit_files = 131072
rlimit_core = unlimited
catch_workers_output = yes

php_admin_value[memory_limit] = 1024M
php_admin_value[max_execution_time] = 300000

php_admin_value[error_log] = /var/log/php-fpm/5.5/www-error.log
php_admin_flag[log_errors] = on

php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/5.5/session

【问题讨论】:

    标签: php magento nginx


    【解决方案1】:

    apc 需要关闭几个小时,然后您可以将其插入并再次读取日志。 还有加速器,有时效果更好。

    禁用整页缓存和 apc 并运行 ab -c 1 -n 1 http://www.campsaver.com/

    然后用 apc 重启

    查看速度、读取日志并启用全页缓存(如果好的话)。

    【讨论】:

    • 亲爱的 Arshad,我还没有在这台服务器上安装 APC
    【解决方案2】:
    Okay,
    
    The above nginx error indicate that issue is related to the fastcgi(php-fpm).
    
    After enabling the "catch_workers_output" on /etc/php5/fpm/pool.d/www.conf Got the relevant error on php5-fpm.log. Now understand that issue is related to AMQP module.
    
    [21-Aug-2013 23:32:57] WARNING: [pool www] child 16091 said into stderr: "php-fpm: pool www: symbol lookup error: /usr/lib/php5/20090626/amqp.so: undefined symbol: amqp_open_socket"
    
    Issue has been fixed afterrecompiled and install amqp module
    

    【讨论】:

    • 亲爱的 Arshad,我启用了 catch_workers_output 并且收到了我在帖子中显示的日志消息。与 amqp 模块没有关系,它没有安装在此服务器上。
    【解决方案3】:

    我注意到您使用的是 PHP 5.5

    根据要求推荐使用的 PHP 版本为 5.2.13 - 5.3.24 http://magento.com/resources/system-requirements

    安装推荐的 PHP 版本,看看有没有问题。

    【讨论】:

      【解决方案4】:

      重启你的 PHP-FPM:

      /etc/init.d/php55-php-fpm restart
      

      如果此问题仍然存在,您可以增加 HTTP 块内的缓冲区和超时:

      http {
          ...
          fastcgi_buffers 8 16k;
          fastcgi_buffer_size 32k;
          fastcgi_connect_timeout 300;
          fastcgi_send_timeout 300;
          fastcgi_read_timeout 300;
          ...
      }
      

      【讨论】:

        猜你喜欢
        • 2020-07-12
        • 2018-06-09
        • 2020-08-27
        • 2014-08-04
        • 2020-04-05
        • 2023-03-20
        • 2023-03-04
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多