Nginx CentOS 7 PHP-FPM 7 502 错误网关

Nginx CentOS 7 PHP-FPM 7 502 错误网关

我已经在 CentOS 7 上配置了 Nginx、PHP-FPM 7。现在出现 502 错误。

在www.conf中:用户和组是nginx。

listen = /var/run/php-fpm.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0660

/var/etc/nginx/conf.d/php-fpm.conf

upstream fastcgi_backend {
    server  unix:/run/php/php-fpm.sock;
}

server {

    listen 80;
    server_name server.com;
    set $MAGE_ROOT /var/www/docroot;
    include /var/www/docroot/nginx.conf.sample;

php-fpm 状态:

php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2017-12-18 15:43:40 EST; 4h 21min ago
 Main PID: 5958 (php-fpm)
   Status: "Processes active: 0, idle: 5, Requests: 0, slow: 0, Traffic: 0req/sec"
   CGroup: /system.slice/php-fpm.service
 ├─5958 php-fpm: master process (/etc/php-fpm.conf)
           ├─5959 php-fpm: pool www
           ├─5960 php-fpm: pool www
           ├─5961 php-fpm: pool www
           ├─5962 php-fpm: pool www
           └─5963 php-fpm: pool www

因此看起来好像 php-fpm 正在监听。但是,网关仍然不好。
对于此设置,任何建议都值得感激。

答案1

您需要修复upstreamnginx 的值,它应该指向listenphp-fpm 指令中定义的套接字

upstream fastcgi_backend {
    server  unix:/var/run/php-fpm.sock;
}

相关内容