Linux下如何查看定位当前正在运行的Nginx的配置文件

1. 查看nginx的PID,以常用的80端口为例:

[root@xiaoyuer scripts]# netstat -lntup|grep 80
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      13309/nginx 

#可以知道nginx进程是13309

2. 通过相应的进程ID(比如:13309)查询当前运行的nginx路径:

[root@xiaoyuer scripts]# ll /proc/13309/exe 
lrwxrwxrwx 1 root root 0 Jan  4 17:02 /proc/13309/exe -> /data/nginx/sbin/nginx

 3. 获取到nginx的执行路径后,使用-t参数即可获取该进程对应的配置文件路径,如:

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

 其实所有的启动命令都是类似 

原文地址:https://www.cnblogs.com/zhaojingyu/p/10229417.html