启动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时,报这么个错:

[[email protected] 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行缺少或者多了个大括号导致这个报错
所以:

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

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