Find the nginx.conf file, my nginx actually uses

Work on a client server where two different versions of nginx are installed. I think one of them was installed with the brew package manager (its osx box), and the other seems to have been compiled and installed with the nginx Makefile package. I searched all the nginx.conf files on the server, but none of these files defines the parameters that nginx actually uses when I run it on the server. Where is the nginx.conf file that I don't know about?

+70
nginx sysadmin macos
Nov 11 '13 at 15:33
source share
5 answers

Running nginx -t through your command line gives a test and adds the result with the file track to the configuration file (with an error or success message).

+144
Nov 11 '13 at 15:38
source share
— -
 % ps -o args -C nginx COMMAND build/sbin/nginx -c ../test.conf 

If nginx was started without the -c option, you can use the -V option to find out the configuration options that were set for 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 
+30
Nov 11 '13 at 17:02
source share

Both nginx -t and nginx -V will print the path to the default nginx configuration file.

 $ nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful $ nginx -V nginx version: nginx/1.11.1 built by gcc 4.9.2 (Debian 4.9.2-10) built with OpenSSL 1.0.1k 8 Jan 2015 TLS SNI support enabled configure 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 configuration file:

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

Even if you downloaded some other configuration file, they will still print the default value.




ps aux will show you the currently loaded nginx configuration file.

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

So that you can get the configuration file, for example:

 $ ps aux | grep "[c]onf" | awk '{print $(NF)}' /app/nginx.conf 
+14
Jul 24 '16 at 0:25
source share
 which nginx 

will give you the path used by nginx

and as mentioned in @Daniel Li

you can get nginx configuration through your method

alternatively you can use this:

 nginx -V 
+2
Apr 14 '16 at 21:01
source share

In addition to @Daniel Li's answer, installing nginx with Valet will also use the Velet configuration, this can be found in "/usr/local/etc/nginx/valet/valet.conf". A nginx.conf file would import this conf file. The necessary settings can be in the Valet file.

+1
Oct 24 '17 at 12:29
source share



All Articles