启动nginx报错nginx: [emerg] unexpected end of file, expecting "}" in /usr/local/nginx/conf/nginx.conf:

启动nginx报错:“nginx: [emerg] unexpected end of file, expecting “}” in /usr/local/nginx/conf/nginx.conf:118”

重启nginx时,报这么个错:

[root@localhost conf]# /usr/local/nginx/sbin/nginx -s reload
nginx: [emerg] unexpected end of file, expecting “}” in /usr/local/nginx/conf/nginx.conf:118

翻译:错误的文件结尾“}”
所以是nginx.conf的118行缺少或者多了个大括号导致这个报错
所以:

[root@localhost nginx]# cd conf/
[root@localhost conf]# grep -Ei “{|}” nginx.conf
events {
}
http {
server {
location / {
}
location = /50x.html {
}
#location ~ .php$ {
#}
location ~ .php$ {
#}
#location ~ /.ht {
#}
}
#server {
# location / {
# }
#}
#server {
# location / {
# }
#}
}

发现确实少了一个大括号
在nginx.conf中加上一个大括号
[root@localhost conf]# vim nginx.conf
在118行插一个}
然后重启一下nginx启动nginx报错nginx: [emerg] unexpected end of file, expecting
完美解决~

你可能感兴趣的:(nginx,nginx,linux,centos)