我是nginx和Raspberry的新手。
我用nginx安装了
sudo apt-get install
那一切都很好。当我尝试重新启动nginx时问题出现了,它抛出了这个错误
nginx.service的作业失败。有关详细信息,请参阅'systemctl status nginx.service'和'journalctl -xn'
调查后我发现问题是下一个错误:
意外的文件结束,期待“;”或/ etc / nginx / sites-enabled / default中的“}”:20
我的默认文件是:
# 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 /
我希望你能帮帮我 :)
正如@Thanh Nguyen Van已经回答的那样。必须用花括号打开和关闭location
,然后为服务器端打开另一个花括号
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;
}
}
}
确保;
在行尾,{ ..}
正确。