502错误的网关-PHP 7,Nginx,Centos

时间:2019-04-18 21:17:33

标签: php nginx centos

我正在尝试配置CentOS 7.3NginxPHP 7.3,但是我得到了:

  

502错误的网关   nginx / 1.10.3

这是site.com.conf:

server {
listen 80;
server_name server IP;
root /var/www/site.com/public;
index index.php index.html index.htm;

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $request_filename;
    include fastcgi_params;    
    }
}

如果我将静态HTML上传到公共目录,则可以看到它,但是如果尝试加载PHP文件,则会看到该错误。 我有/var/run/php-fpm/php-fpm.sock

1 个答案:

答案 0 :(得分:0)

解决方案是将listen.owner中的listen.groups/etc/php-fpm.d/www.conf更改为nginx

listen.owner = nginx
listen.group = nginx

然后使用service php-fpm restart重新启动。 您可以使用以下方法检查错误:systemctl status php-fpm.service

相关问题