如何修复未知的内部服务器错误(500)Nginx给了我什么?

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

相关文章

Nginx (engine x) 是一个高性能的HTTP和反向代理服务,也是一...
本地项目配置 1 复制 luffy/settings/dev.py为prop.py 修改l...
nginx不仅可以隐藏版本信息,还支持自定义web服务器信息 先看...
一 、此次漏洞分析 1 nginx HTTP/2漏洞 [nginx-announce] ng...
###进入nginx 目录cd /usr/local/nginx###递归显示 2 级目录...
在cmd命令窗口输入下面命令进行查看 tasklist /fi "ima...