【问题标题】:502 Bad gateway - PHP 7, Nginx, Centos502 网关错误 - PHP 7、Nginx、Centos
【发布时间】:2019-04-19 06:21:23
【问题描述】:

我正在尝试配置 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

【问题讨论】:

    标签: php nginx centos


    【解决方案1】:

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

    listen.owner = nginx
    listen.group = nginx
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-06
      • 1970-01-01
      • 2012-04-17
      • 2011-03-12
      • 2011-05-14
      • 2019-06-05
      • 2015-08-10
      • 2021-11-19
      相关资源
      最近更新 更多