Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save benjaminblack/e95bf36ce726a0d4303ae98aa1d9ce60 to your computer and use it in GitHub Desktop.

Select an option

Save benjaminblack/e95bf36ce726a0d4303ae98aa1d9ce60 to your computer and use it in GitHub Desktop.
Homebrew Nginx sets log, configuration, and pid file locations at compile time

After much head-scratching trying to figure out from where by default Nginx decides to read its main configuration file, and where it decides to write its log files, it turns out that they are all set at compile time (configuration options broken onto separate lines for clarity):

$ nginx -V
nginx version: nginx/1.12.1
built by clang 8.1.0 (clang-802.0.42)
built with OpenSSL 1.1.0f  25 May 2017
TLS SNI support enabled
configure arguments: 
--prefix=/usr/local/Cellar/nginx/1.12.1 
--with-http_ssl_module 
--with-pcre 
--sbin-path=/usr/local/Cellar/nginx/1.12.1/bin/nginx 
--with-cc-opt='-I/usr/local/opt/pcre/include -I/usr/local/opt/[email protected]/include' 
--with-ld-opt='-L/usr/local/opt/pcre/lib -L/usr/local/opt/[email protected]/lib' 
--conf-path=/usr/local/etc/nginx/nginx.conf 
--pid-path=/usr/local/var/run/nginx.pid 
--lock-path=/usr/local/var/run/nginx.lock 
--http-client-body-temp-path=/usr/local/var/run/nginx/client_body_temp 
--http-proxy-temp-path=/usr/local/var/run/nginx/proxy_temp 
--http-fastcgi-temp-path=/usr/local/var/run/nginx/fastcgi_temp 
--http-uwsgi-temp-path=/usr/local/var/run/nginx/uwsgi_temp 
--http-scgi-temp-path=/usr/local/var/run/nginx/scgi_temp 
--http-log-path=/usr/local/var/log/nginx/access.log 
--error-log-path=/usr/local/var/log/nginx/error.log 
--with-http_gzip_static_module 
--with-http_v2_module

Notably, aside from the hard-coded paths in /usr/share/var/, the prefix is compiled to /usr/local/Cellar/nginx/1.12.1. Therefore, relative paths in Nginx configuration rules are relative to that location. So if you use rules with relative paths, e.g. error_log logs/notice.log notice, and you can't find your Nginx output files, look there first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment