启动nginx提示sites-enabled和.conf配置出错

2014-01-10 23:11:34 +08:00
 W1nd
给树莓派安装了nginx,但是发现不能start,查了资料和各种调试,还是存在问题,求各位V2exer帮忙。。
这是sites-enabled的配置:
https://gist.github.com/8355928
.conf配置:
https://gist.github.com/8355911
使用sudo nginx -t出现的错误提示:
nginx: [emerg] unexpected "}" in /etc/nginx/nginx.conf:17
nginx: configuration file /etc/nginx/nginx.conf test failed
11610 次点击
所在节点    NGINX
15 条回复
dorentus
2014-01-10 23:20:33 +08:00
15 16 行末没分号
SErHo
2014-01-10 23:20:58 +08:00
不是提示得很清楚嘛,去17行附近看一下,分号少了吧。
yinxingren
2014-01-10 23:21:58 +08:00
17报错,16root那里少了一个分号
dorentus
2014-01-10 23:22:25 +08:00
另外你既然把网站配置单独拿出来了,就没必要再在 nginx.conf 里面再写一遍了吧(11~18 行)
W1nd
2014-01-10 23:30:27 +08:00
@dorentus 谢谢提醒,因为不确定所以我都写进去了。
fire9
2014-01-11 03:06:12 +08:00
server {
listen 80;
server_name rpi.w1nd.me;
location / {
root /home/pi/octopress
index index.htm index.html
}
}
在nginx.conf里面去掉这段代码。
W1nd
2014-01-11 20:08:06 +08:00
@fire9 我已去掉了。。现在又出现了新的问题。。
tanyuxiang
2014-01-11 20:45:59 +08:00
server {
listen 80;
server_name rpi.w1nd.me;
location / {
root /home/pi/octopress;
index index.html index.htm;
}
}

你最后一个}用来干嘛?
tanyuxiang
2014-01-11 20:49:20 +08:00
看错。。。。

default.save这个文件内容是什么
删掉吧。。。
W1nd
2014-01-11 21:09:19 +08:00
@tanyuxiang 谢谢,原来是个文件,我删掉了。。再测试了下

nginx: [emerg] unexpected "}" in /etc/nginx/sites-enabled/default~:6
nginx: configuration file /etc/nginx/nginx.conf test failed

变成这样了,,真不知道问题到底出在哪。。
yinxingren
2014-01-11 21:11:13 +08:00
@W1nd 你default第六行又错了,猜测是前一行掉了一个分号.
dorentus
2014-01-11 21:13:36 +08:00
不是 default,是 /etc/nginx/sites-enabled/default~ ,应该是你的编辑器自动保存的备份文件。

因为你的 nginx.conf 里面写了 include /etc/nginx/sites-enabled/* 来包含 /etc/nginx/sites-enabled/ 目录下的所有文件,所以它也被 include 进去了。

删掉它。
dorentus
2014-01-11 21:15:14 +08:00
PS:

> nginx: [emerg] unexpected "}" in /etc/nginx/sites-enabled/default.save:33

说的是文件 /etc/nginx/sites-enabled/default.save 的第 33 行有语法错误:unexpected "}"
W1nd
2014-01-11 21:27:19 +08:00
@dorentus 谢谢,问题解决了。原来就是因为多了备份文件,所以提示出错。再次感谢!!
yangg
2014-01-11 21:31:28 +08:00
@W1nd 可以把incldue那里改成 path/to/sites-enabled/*.conf

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/96510

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX