我正在尝试配置 CentOS 7.3
, Nginx
和 PHP 7.3
,但我得到:
502 Bad Gateway 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 上传到公共(public)目录,我可以看到它,但如果我尝试加载 PHP 文件,我会看到该错误。
我有
/var/run/php-fpm/php-fpm.sock
.
最佳答案
解决方案是更改 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
.
关于php - 502 网关错误 - PHP 7、Nginx、Centos,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55753840/