更新时间:2022-10-14 09:59:13
【问题描述】
更改完nginx.conf文件后,执行/app/nginx/sbin/nginx -s reload命令重新加载配置文件,报以下错误信息:
1
|
nginx: [alert] kill(2480, 10) failed (3: No such process) |
提示没有相关进程。
【解决】
其实这个问题很低级的说,就是我之前压根就没有启动nginx服务,执行/app/nginx/sbin/nginx,开启nginx服务后,重新加载nginx配置,一切正常!
【附录】
nginx帮助信息
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# /app/nginx/sbin/nginx -h nginx version: nginx/1.6.3 Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives] Options: -?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /app/nginx-1.6.3/)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file
|
nginx服务管理常用命令
1
2
3
4
5
6
7
8
|
/app/nginx/sbin/nginx -h 查看nginx帮助信息 nginx -s stop, — fast shutdown nginx -s quit, — graceful shutdown 字面意思为优雅的关闭,个人理解应该是安全的关闭吧 nginx -s reopen — reopening the log files 重新打开日志文件 nginx -s reload — reloading the configuration file 重新加载配置文件 # /app/nginx/sbin/nginx -t 检查配置 nginx: the configuration file /app/nginx-1.6.3/conf/nginx.conf syntax is ok nginx: configuration file /app/nginx-1.6.3/conf/nginx.conf test is successful |
关闭nginx服务
# /app/nginx/sbin/nginx -s stop
# pkill -9 nginx 强制关闭
ps -ef |head -1;ps -ef |grep nginx
UID PID PPID C STIME TTY TIME CMD
root 2114 1 0 00:39 ? 00:00:00 nginx: master process /app/nginx/sbin/nginx
nginx 2115 2114 0 00:39 ? 00:00:00 nginx: worker process
root 2126 1660 0 00:41 pts/0 00:00:00 grep nginx
# kill 2114
# pgrep nginx
# /app/nginx/sbin/nginx
# pgrep nginx
2150
2151
ps -A | grep nginx | grep -v grep | awk '{ print $1; }' |head -1 |xargs -L 1 kill -QUIT
使用xargs -L 1确保每次只取一行内容,然后使用kill -QUIT关闭nginx
启动nginx服务
/app/nginx/sbin/nginx
# ps -ef |head -1;ps -ef |grep nginx
UID PID PPID C STIME TTY TIME CMD
root 2157 1 0 00:47 ? 00:00:00 nginx: master process /app/nginx/sbin/nginx
nginx 2158 2157 0 00:47 ? 00:00:00 nginx: worker process
root 2174 1660 0 00:52 pts/0 00:00:00 grep nginx
# kill -HUP 2157
#
# pgrep nginx
2157
2175
对配置文件更改后,可使用kill -HUP命令在不停止原有服务的情况下重新加载配置,有点nginx -s reload的味道。