1

I have configured Nginx, PHP-FPM 7 on CentOS 7. I am now having a 502 error.

In www.conf: user and group are nginx.

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

In /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 status:

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

So it seems as though php-fpm is listening. Yet, still bad gateway.
New to this setup, any suggestions would be appreciated.

kasperd
  • 29,894
  • 16
  • 72
  • 122
freddyk
  • 11
  • 1
  • 2

1 Answers1

1

you need to fix upstream value for nginx, it should be pointed to socket defined in listen directive of php-fpm

upstream fastcgi_backend {
    server  unix:/var/run/php-fpm.sock;
}
Quantim
  • 1,269
  • 11
  • 13