netstat命令
用于显示与IP、TCP、UDP和ICMP协议相关的统计数据,一般用于检验本机各端口的网络连接情况
netstat -lntup
说明: l:listening n:num t:tcp u:udp p:process
- 查看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
- 通过相应的进程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
其实所有的启动命令都是类似