这里是scee.conf –
pid ./pid; error_log ./error_log debug; events { worker_connections 1024; } http { access_log ./access_log; server { listen 31415; } }
我运行它使用
nginx -c scee.conf -p .
(从它所在的目录运行)
大多数东西都logging在configuration文件所在的同一目录下的error.log中,但是神奇的是,每次重启nginx时,下面这行就会继续logging到/var/log/nginx/error.log –
2015/05/06 21:41:39 [notice] 2231#0: signal process started
或类似的。
这很烦人,因为它需要运行nginx的用户写/ var / log / nginx。 这里发生了什么?
输出nginx -V
nginx version: nginx/1.4.6 (Ubuntu) built by gcc 4.8.2 (Ubuntu 4.8.2-19ubuntu1) TLS SNI support enabled configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module
什么是–error-log-path编译器标志在这里做? 它是否简单地控制日志的默认位置,如果您的configuration文件中没有error_log指令?
检查您的configuration中是否有多个服务器块。 在我的情况下,我认为这是由像下面的HTTPredirect造成的。 HTTP请求被logging在默认的日志path中,但是HTTPS请求被logging在我预期的地方。
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; return 301 https://example.com$request_uri; } server { listen 443; access_log /path/to/my.log; ... }