查看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
通过相应的进程ID(比如:48963)查询当前运行的nginx路径:
[root@master ~]# ll /proc/48963/exe
lrwxrwxrwx 1 root root 0 6月 24 16:29 /proc/48963/exe -> /usr/sbin/nginx
获取到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