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

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

  1. 查看nginx的PID,以常用的80端口为例:
如果知道端口号,可以用端口号查询
[root@master ~]# netstat -lntup| grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      48963/nginx: master 
tcp6       0      0 :::80                   :::*                    LISTEN      48963/nginx: master 
 

不知道端口号,直接通过服务名称查询
[root@master ~]# netstat -lntup| grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      48963/nginx: master 
tcp6       0      0 :::80                   :::*                    LISTEN      48963/nginx: master 
 
 
#可以知道nginx进程是48963
  1. 通过相应的进程ID(比如:48963)查询当前运行的nginx路径:
[root@master ~]# ll /proc/48963/exe 
lrwxrwxrwx 1 root root 0 6月  24 16:29 /proc/48963/exe -> /usr/sbin/nginx

  1. 获取到nginx的执行路径后,使用-t参数即可获取该进程对应的配置文件路径,如:
[root@master ~]# /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

源码还是yum安装的方法都是一样的,没有区别

你可能感兴趣的:(nginx,nginx,linux,服务器)