How can I find out where the nginx configuration file is located?

For an unfamiliar server or the installation has been too long to forget the location, how can we easily and quickly find the location of the configuration file?
To find out the location of the configuration file, you need to find the path to the nginx executable first,

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 does not run

View the software installation path

whereis nginx

Query the path where the running file is located

which nginx

Of course there are other ways to query

rpm package installed, you can use rpm -qa | grep "software or package name" query;
yum method installed, you can use yum list installed to find;

I have a few Alibaba Cloud lucky coupons to share with you. There will be special surprises for purchasing or upgrading Alibaba Cloud products with the coupons! Take all the lucky coupons for the products you want to buy! Hurry up, it's about to be sold out.

Get configuration file location

Through some of the above methods, after finding the path of the nginx executable file, you can find the location of the configuration file through the functions of Nginx itself.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325277501&siteId=291194637