免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 34836 | 回复: 5
打印 上一主题 下一主题

[服务应用] 帮忙看一下这段Nginx配置文件哪里错了? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-03-25 08:58 |只看该作者 |倒序浏览
测试的时候报错说nginx: [emerg] unexpected "}" in /usr/local/nginx/conf/nginx.conf:144
得知是144行的}有错误(也就是最后一行的大括号),我查看了好几次,都没发现}有什么不对的地方?
请帮忙看下
谢谢了!
  1. user  nobody;
  2. worker_processes  1;
  3. #error_log  logs/error.log;
  4. #error_log  logs/error.log  notice;
  5. #error_log  logs/error.log  info;
  6. pid        logs/nginx.pid;
  7. worker_rlimit_nofile 65535;
  8. events {
  9.     use epoll;
  10.     worker_connections  65535;
  11. }


  12. http {
  13.     include       mime.types;
  14.     default_type  application/octet-stream;
  15.     client_header_buffer_size 32k;
  16.     large_client_header_buffers 4 32k;
  17.     client_max_body_size 8m;

  18.     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  19.     #                  '$status $body_bytes_sent "$http_referer" '
  20.     #                  '"$http_user_agent" "$http_x_forwarded_for"';

  21.     #access_log  logs/access.log  main;

  22.     sendfile        on;
  23.     tcp_nopush     on;

  24.     #keepalive_timeout  0;
  25.     keepalive_timeout  60;
  26.     tcp_nodelay on;
  27.    


  28.     gzip  on;
  29.     gzip_min_length 1k;
  30.     gzip_buffers        4 16k;
  31.     gzip_http_version 1.0;
  32.     gzip_comp_level 2;
  33.     gzip_types        test/plain application/x-javescript text/css application/xlm;
  34.     gzip_vary on;

  35.     upstream backend
  36.     {
  37.             server 192.168.1.20:80;
  38.         server 192.168.1.50:80;
  39.     }

  40.     server {
  41.         listen       80;
  42.         server_name  www.kevintest.com;

  43.         #charset koi8-r;

  44.         #access_log  logs/host.access.log  main;

  45.         location / {
  46.             root   html;
  47.             index  index.html index.htm;
  48.             proxy_redirect off;
  49.             proxy_set_header Host $host;
  50.             proxy_set_header X-Real-IP $remote_addr;
  51.             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  52.             proxy_pass http://backend;
  53.         }

  54.         location /nginx {
  55.         access_log on;
  56.         auth_basic "NginxStatus";
  57.         auth_basic_user_file /usr/local/nginx/htpasswd;
  58.         }
  59.             log_format  access  '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" '
  60.         access_log /usr/local/nginx/log/access.log access
  61.        

  62.         #error_page  404              /404.html;

  63.         # redirect server error pages to the static page /50x.html
  64.         #
  65.         #error_page   500 502 503 504  /50x.html;
  66.         #location = /50x.html {
  67.         #    root   html;
  68.         #}

  69.         # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  70.         #
  71.         #location ~ \.php$ {
  72.         #    proxy_pass   http://127.0.0.1;
  73.         #}

  74.         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  75.         #
  76.         #location ~ \.php$ {
  77.         #    root           html;
  78.         #    fastcgi_pass   127.0.0.1:9000;
  79.         #    fastcgi_index  index.php;
  80.         #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
  81.         #    include        fastcgi_params;
  82.         #}

  83.         # deny access to .htaccess files, if Apache's document root
  84.         # concurs with nginx's one
  85.         #
  86.         #location ~ /\.ht {
  87.         #    deny  all;
  88.         #}
  89.         #    }


  90.     # another virtual host using mix of IP-, name-, and port-based configuration
  91.     #
  92.     #server {
  93.     #    listen       8000;
  94.     #    listen       somename:8080;
  95.     #    server_name  somename  alias  another.alias;

  96.     #    location / {
  97.     #        root   html;
  98.     #        index  index.html index.htm;
  99.     #    }
  100.     #}


  101.     # HTTPS server
  102.     #
  103.     #server {
  104.     #    listen       443;
  105.     #    server_name  localhost;

  106.     #    ssl                  on;
  107.     #    ssl_certificate      cert.pem;
  108.     #    ssl_certificate_key  cert.key;

  109.     #    ssl_session_timeout  5m;

  110.     #    ssl_protocols  SSLv2 SSLv3 TLSv1;
  111.     #    ssl_ciphers  HIGH:!aNULL:!MD5;
  112.     #    ssl_prefer_server_ciphers   on;

  113.     #    location / {
  114.     #        root   html;
  115.     #        index  index.html index.htm;
  116.     }
  117. }
复制代码

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
2 [报告]
发表于 2013-03-25 09:09 |只看该作者
你的73,74行末尾是不是少了分号?

论坛徽章:
0
3 [报告]
发表于 2013-03-25 09:18 |只看该作者
chenyx 发表于 2013-03-25 09:09
你的73,74行末尾是不是少了分号?


哦 的确是啊,我怎么说老是报错说大括号有问题,原来是上一行的问题 汗!

但是 又报错了
nginx: [emerg] open() "/usr/local/nginx/log/access.log" failed (2: No such file or directory)
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
郁闷了,明明有access.log这个文件的,
权限也修改成nobody:nobody了 就是提示这个error  悲剧 能不能帮忙看下?谢谢楼!

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
4 [报告]
发表于 2013-03-25 09:26 |只看该作者
你检查下log目录的权限.

论坛徽章:
0
5 [报告]
发表于 2013-03-25 14:15 |只看该作者
chenyx 发表于 2013-03-25 09:26
你检查下log目录的权限.


谢谢 问题解决

论坛徽章:
0
6 [报告]
发表于 2014-09-29 15:48 |只看该作者
麻烦问一下 ,你这个问题是怎么解决的! 我也遇见类似的问题了!  原本的access.log 文件没有,我新建了一个 并给了777 的权限 找不到是什么问题
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP