nginx-error_log重定向
阿新 • • 發佈:2018-08-24
uil events acc dir cat out con app test 編譯模塊
-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重定向