Find out where the nginx configuration file is located

  • 2020-05-17 07:44:28
  • OfStack

For 1 unfamiliar server or installation too long to forget the location, how to find the location of the configuration file quickly and easily? To find the location of the configuration file, you need to find the path to the nginx executable. Here are a few ways to do this:

1. If the program is running ps -ef | grep nginx # ps -ef | grep nginx root 29514...

For 1 unfamiliar server or installation too long to forget the location, how to find the location of the configuration file quickly and easily?
To find the location of the configuration file, you need to find the path to the nginx executable,

Here are a few ways:

1. If the program is running


ps -ef | grep nginx
# ps -ef | grep nginx 
root   29514   1 0 Mar01 ?    00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 29515 29514 0 Mar01 ?    00:00:00 nginx: worker process
root   30276 28948 0 09:36 pts/1  00:00:00 grep --color=auto nginx

Usually/usr/sbin/nginx

2. The program is not running

View the software installation path

whereis nginx

Query the path where the run file is located

which nginx

There are, of course, other query methods

If the rpm package is installed, you can use rpm-qa | grep "name of the software or package".
yum method installed, you can use yum list installed;

Gets the configuration file location

After you find the path to the nginx executable using the methods above, you can find the location of the configuration file through Nginx's own functions.


# /usr/sbin/nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Do you have a better way?

conclusion


Related articles: