nginx文件意外结束,应为“0”&引用;或&引用;在/etc/nginx/sites enabled/default:20比Raspbian高
我是nginx和Raspberry的新手 我使用 sudoapt安装 那时一切都很好。当我尝试重新启动nginx时,问题出现了,它抛出了这个错误 nginx.service的作业失败。有关详细信息,请参阅“systemctl status ngins.service”和“journaldtl-xn” 经过调查,我发现问题在于下一个错误: 意外的文件结尾,在/etc/nginx/sites enabled/default:20中应为“;”或“}” 我的默认文件是:nginx文件意外结束,应为“0”&引用;或&引用;在/etc/nginx/sites enabled/default:20比Raspbian高,nginx,raspbian,raspberry-pi3,Nginx,Raspbian,Raspberry Pi3,我是nginx和Raspberry的新手 我使用 sudoapt安装 那时一切都很好。当我尝试重新启动nginx时,问题出现了,它抛出了这个错误 nginx.service的作业失败。有关详细信息,请参阅“systemctl status ngins.service”和“journaldtl-xn” 经过调查,我发现问题在于下一个错误: 意外的文件结尾,在/etc/nginx/sites enabled/default:20中应为“;”或“}” 我的默认文件是: # Please see /us
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
listen 80;
server_name $domain_name;
root /var/www;
index index.html index.htm;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# Make site accessible from http://localhost/
server_name localhost;
location /
我希望您能帮助我:)更正您的nginx文件,如下所示: 例如:
http {
upstream api-app {
.....................;
}
........................;
server {
location / {
...................;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
}
确保
代码>在行尾,并且{..}
正确。因为@Thanh Nguyen Van已经回答了。位置
必须用大括号打开和关闭,然后在服务器端用另一个大括号打开和关闭
server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
listen 80;
server_name $domain_name;
root /var/www;
index index.html index.htm;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# Make site accessible from http://localhost/
server_name localhost;
location / {
}
}
我也有同样的问题。
确认有一个丢失的
在服务器块内新添加的行的末尾{…}
确保大括号和代码>全部到位同时确保没有意外的引号(单引号或双引号)。我花了一段时间才弄清楚有一次我使用Docker并将该值作为env var传递,所以它被错误地引用了
因此,这将是一个不正确的位:
upstream backend {
"server localhost:9000;"
}
这是正确的:
upstream backend {
server localhost:9000;
}
我的问题是由于缺少一个
作为命令行参数之一的一部分
以下是我的日志供参考:
2020/08/11 17:19:25 [emerg] 1#1: unexpected end of parameter, expecting ";" in command line
nginx: [emerg] unexpected end of parameter, expecting ";" in command line
我的错误是我通过docker使用以下CMD
启动了nginx
:
CMD ["nginx", "-g", "daemon off"]
在这里,我丢失了尾随的代码>。我应该做的是:
CMD ["nginx", "-g", "daemon off;"]
以防万一,它可以帮助其他人。您能在默认文件中显示第20行吗?正是下面的那行:location/I尝试写入´},但不起作用。事实上,我没有修改该文件:/Thank。我只是在位置块{}.Gah内新添加的一行末尾漏掉了一个“;”,很容易漏掉。我正在翻我的配置,但找不到它。就是这样。