启动nginx提示sites-enabled和.conf配置出错 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
W1nd
V2EX    NGINX

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

  •  
  •   W1nd 2014-01-10 23:11:34 +08:00 12293 次点击
    这是一个创建于 4373 天前的主题,其中的信息可能已经有所发展或是发生改变。
    给树莓派安装了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     Solana     1170 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 28ms UTC 17:26 PVG 01:26 LAX 09:26 JFK 12:26
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86