Nginx给了我一个500错误,让我发疯.首先,我在/etc/Nginx/conf.d/中有一个personalsite.conf存档,我有我的服务器块.
这是我的服务器块配置:
server {
listen 80;
server_name personalsite.me;
charset UTF-8;
access_log /var/log/Nginx/personalsite.access.log main;
error_log /var/log/Nginx/personalsite.error.log;
root /usr/share/Nginx/html/personalsite;
index index.PHP index.html index.htm;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/Nginx/html/;
}
location ~ \.PHP${
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/PHP-fpm/PHP-fpm.sock;
fastcgi_index index.PHP;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
加上Nginx用户在/usr/share / Nginx / html / personalsite /上签署了适当的权限.
当我尝试浏览personalsite.me时,Nginx给了我一个500错误,有趣的是我知道这是因为我检查了personalsite.access.log并看到它,因为浏览器只是空白.由于未知原因,Nginx无法向我显示其500错误页面,正如您所见,在服务器块中正确声明.
另一件奇怪的事情是,personalsite.error.log是空白的,它什么都没记录.
此外,我在/ etc / hosts存档中使用其IP声明了该域.所以我真的不知道这里发生了什么.
一切都在通过数字海洋VPS运行CentOS 7.
解决方法:
在Nigix设置时,由于配置错误导致大多数错误.我建议检查文件(/etc/PHP-fpm.d/www.conf).
vi /etc/PHP-fpm.d/www.conf
找到指定listen参数的行,并将其更改为如下所示:
listen = /var/run/PHP-fpm/PHP-fpm.sock
接下来,找到设置listen.owner和listen.group的行并取消注释它们.他们应该是这样的:
listen.owner = nobody
listen.group = nobody
最后,找到设置用户和组的行,并将其值从“apache”更改为“Nginx”:
user = Nginx
group = Nginx
然后保存并退出
/etc/init.d PHP-fpm restart