Locate the nginx.conf file my nginx is actually using Locate the nginx.conf file my nginx is actually using nginx nginx

Locate the nginx.conf file my nginx is actually using


Running nginx -t through your commandline will issue out a test and append the output with the filepath to the configuration file (with either an error or success message).


Both nginx -t and nginx -V would print out the default nginx config file path.

$ nginx -tnginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful$ nginx -Vnginx version: nginx/1.11.1built by gcc 4.9.2 (Debian 4.9.2-10)built with OpenSSL 1.0.1k 8 Jan 2015TLS SNI support enabledconfigure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf ...

If you want, you can get the config file by:

$ nginx -V 2>&1 | grep -o '\-\-conf-path=\(.*conf\)' | cut -d '=' -f2/etc/nginx/nginx.conf

Even if you have loaded some other config file, they would still print out the default value.


ps aux would show you the current loaded nginx config file.

$ ps auxUSER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMANDroot        11  0.0  0.2  31720  2212 ?        Ss   Jul23   0:00 nginx: master process nginx -c /app/nginx.conf

So that you could actually get the config file by for example:

$ ps aux | grep "[c]onf" | awk '{print $(NF)}'/app/nginx.conf


% ps -o args -C nginxCOMMANDbuild/sbin/nginx -c ../test.conf

If nginx was run without the -c option, then you can use the -V option to find out the configure arguments that were set to non-standard values. Among them the most interesting for you are:

--prefix=PATH                      set installation prefix--sbin-path=PATH                   set nginx binary pathname--conf-path=PATH                   set nginx.conf pathname