linux查看nginx启动路径
由于系统中有多个nginx目录,不知道哪一个哪一个才是真正的正在运行的服务,记录查看nginx启动路径定位。
查找nginx的pid
1 2 | [root@wskh xpe] # netstat -anop | grep 0.0.0.0:80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2320 /nginx : master off (0.00 /0/0 ) |
查找指定pid正在运行服务的启动路径
1 2 | [root@wskh xpe] # ll /proc/2320/exe lrwxrwxrwx 1 root root 0 11月 16 11:29 /proc/2320/exe -> /usr/local/nginx/sbin/nginx |
查找nginx启动使用的配置文件
1 2 3 | [root@wskh xpe] # /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 |
linux nginx启动、停止、重启命令
下载安装
1 2 3 4 | #Install the prerequisites: sudo yum install yum-utils #install nginx sudo yum install nginx |
启动
1 2 3 4 5 6 | #使用默认的配置启动 sudo nginx #指定配置启动 /etc/nginx/nginx.conf 替换为自己的配置 sudo nginx -c /etc/nginx/nginx .conf #指定错误日志路径 /etc/nginx/error.log 替换为自己的配置 sudo nginx -e /etc/nginx/error .log |
停止
1 2 3 4 5 6 7 8 9 10 | #fast shutdown nginx -s stop #优雅的关闭 nginx -s quit #查询启动的nginx ps -ax | grep nginx # 强制kill nginx kill -9 pid # 优雅 kikk kill -s QUIT pid |
重启
1 2 3 4 | #1. 验证配置是否正确 nginx -t #2. 加载并应用新的配置 nginx -s reload |
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持IT俱乐部。