V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
W1nd
V2EX  ›  NGINX

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

  •  
  •   W1nd · 2014-01-10 23:11:34 +08:00 · 11603 次点击
    这是一个创建于 3757 天前的主题,其中的信息可能已经有所发展或是发生改变。
    给树莓派安装了nginx,但是发现不能start,查了资料和各种调试,还是存在问题,求各位V2exer帮忙。。
    这是sites-enabled的配置:

    .conf配置:

    使用sudo nginx -t出现的错误提示:
    nginx: [emerg] unexpected "}" in /etc/nginx/nginx.conf:17
    nginx: configuration file /etc/nginx/nginx.conf test failed
    第 1 条附言  ·  2014-01-11 20:07:02 +08:00
    依据各位V友的解答,改正了.conf
    但是又出现了新的问题(sites-enabled没有改动):
    nginx: [emerg] unexpected "}" in /etc/nginx/sites-enabled/default.save:33
    nginx: configuration file /etc/nginx/nginx.conf test failed

    不懂save:33..
    15 条回复    1970-01-01 08:00:00 +08:00
    dorentus
        1
    dorentus  
       2014-01-10 23:20:33 +08:00 via iPhone   ❤️ 1
    15 16 行末没分号
    SErHo
        2
    SErHo  
       2014-01-10 23:20:58 +08:00 via Android   ❤️ 1
    不是提示得很清楚嘛,去17行附近看一下,分号少了吧。
    yinxingren
        3
    yinxingren  
       2014-01-10 23:21:58 +08:00 via Android   ❤️ 1
    17报错,16root那里少了一个分号
    dorentus
        4
    dorentus  
       2014-01-10 23:22:25 +08:00 via iPhone   ❤️ 1
    另外你既然把网站配置单独拿出来了,就没必要再在 nginx.conf 里面再写一遍了吧(11~18 行)
    W1nd
        5
    W1nd  
    OP
       2014-01-10 23:30:27 +08:00
    @dorentus 谢谢提醒,因为不确定所以我都写进去了。
    fire9
        6
    fire9  
       2014-01-11 03:06:12 +08:00   ❤️ 1
    server {
    listen 80;
    server_name rpi.w1nd.me;
    location / {
    root /home/pi/octopress
    index index.htm index.html
    }
    }
    在nginx.conf里面去掉这段代码。
    W1nd
        7
    W1nd  
    OP
       2014-01-11 20:08:06 +08:00
    @fire9 我已去掉了。。现在又出现了新的问题。。
    tanyuxiang
        8
    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
        9
    tanyuxiang  
       2014-01-11 20:49:20 +08:00   ❤️ 1
    看错。。。。

    default.save这个文件内容是什么
    删掉吧。。。
    W1nd
        10
    W1nd  
    OP
       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
        11
    yinxingren  
       2014-01-11 21:11:13 +08:00
    @W1nd 你default第六行又错了,猜测是前一行掉了一个分号.
    dorentus
        12
    dorentus  
       2014-01-11 21:13:36 +08:00   ❤️ 1
    不是 default,是 /etc/nginx/sites-enabled/default~ ,应该是你的编辑器自动保存的备份文件。

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

    删掉它。
    dorentus
        13
    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
        14
    W1nd  
    OP
       2014-01-11 21:27:19 +08:00
    @dorentus 谢谢,问题解决了。原来就是因为多了备份文件,所以提示出错。再次感谢!!
    yangg
        15
    yangg  
       2014-01-11 21:31:28 +08:00
    @W1nd 可以把incldue那里改成 path/to/sites-enabled/*.conf
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1137 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 81ms · UTC 18:49 · PVG 02:49 · LAX 11:49 · JFK 14:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.