码迷,mamicode.com
首页 > 其他好文 > 详细

nginx-error_log重定向

时间:2018-08-24 16:03:34      阅读:306      评论:0      收藏:0      [点我收藏+]

标签:version   --   sni   bash   live   process   red   test   nss   

  • 编译模块
  •  -bash-4.1# ./sbin/nginx -V
    nginx version: nginx/
    built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) 
    built with OpenSSL 1.0.1e-fips 11 Feb 2013
    TLS SNI support enabled
    configure arguments: --with-http_ssl_module --with-http_stub_status_module --error-log-path=/usr/local/nginx/log/error.log
    • nginx主配置文件
    
     -bash-4.1# cat conf/nginx.conf
    worker_processes  1;
    error_log /usr/local/nginx/log/error.log;
    
    events {
        worker_connections  1024;
    }
    
    http {
         include mime.types;
         default_type application/octet-stream;
         sendfile on;
         keepalive_timeout 65;
         include  test/*;
    }
    • 测试
     -bash-4.1# > log/error.log
    -bash-4.1# > logs/error.log
    -bash-4.1# sed ‘s/\(^error_log.*\)/\1\naccess_log\ \ \/usr\/local\/nginx\/log\/access.log;/‘ conf/nginx.conf
    worker_processes  1;
    error_log /usr/local/nginx/log/error.log;
    access_log  /usr/local/nginx/log/access.log;
    
    events {
        worker_connections  1024;
    }
    
    http {
         include mime.types;
         default_type application/octet-stream;
         sendfile on;
         keepalive_timeout 65;
         include  test/*;
    }
    -bash-4.1# sed -i ‘s/\(^error_log.*\)/\1\naccess_log\ \ \/usr\/local\/nginx\/log\/access.log;/‘ conf/nginx.conf
    -bash-4.1# ./sbin/nginx -t
    nginx: [emerg] "access_log" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:3
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
    -bash-4.1# ./sbin/nginx -s reload
    nginx: [emerg] "access_log" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:3
    -bash-4.1# cat log/error.log 
    2018/08/24 14:45:43 [emerg] 5258#0: "access_log" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:3
    2018/08/24 14:45:47 [emerg] 5267#0: "access_log" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:3
    -bash-4.1# cat logs/error.log 
    -bash-4.1# 
    • 复原
    -bash-4.1# sed -i ‘3d‘ conf/nginx.conf
    -bash-4.1# cat conf/nginx.conf
    worker_processes  1;
    error_log /usr/local/nginx/log/error.log;
    
    events {
        worker_connections  1024;
    }
    
    http {
         include mime.types;
         default_type application/octet-stream;
         sendfile on;
         keepalive_timeout 65;
         include  test/*;
    }
    -bash-4.1# ./sbin/nginx -t
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    -bash-4.1# ./sbin/nginx -s reload

    nginx-error_log重定向

    标签:version   --   sni   bash   live   process   red   test   nss   

    原文地址:http://blog.51cto.com/13747009/2163872

    (0)
    (0)
       
    举报
    评论 一句话评论(0
    登录后才能评论!
    © 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
    迷上了代码!