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安装的方法都是一样的,没有区别

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值