基本命令
1. 入门
查看nginx进程:
ps -ef|grep nginx
404@40401:~$ ps -ef|grep nginx root 7996 1 0 Apr14 ? 00:00:00 nginx: master process nginx 404 14126 6118 0 11:56 pts/79 00:00:00 more nginx.conf 404 18278 7635 0 13:16 pts/88 00:00:00 grep --color=auto nginx nobody 31455 7996 0 Jun01 ? 00:03:26 nginx: worker process nobody 31456 7996 0 Jun01 ? 00:03:35 nginx: worker process nobody 31457 7996 0 Jun01 ? 00:03:25 nginx: worker process nobody 31458 7996 0 Jun01 ? 00:03:40 nginx: worker process
这里进程的话主要由nobody执行,为什么是4个事因为在ngin.conf中设置了四核
## worker_processes的数值设置为cpu的核数 worker_processes 4; ## 绑定每个nginx进程所使用的CPU,使nginx可以利用cpu的多核 worker_cpu_affinity 0001 0010 0100 1000;
检查配置文件的正确性:
sudo nginx -t
404@40401:~/env/nginx/default/conf$ sudo nginx -t [sudo] password for work: nginx: the configuration file 404/nginx.conf syntax is ok nginx: configuration file 404/nginx.conf test is successful
检查nginx完整配置信息:
sudo nginx -V
nginx -V
启动nginx:
- nginx
- nginx -s reload: 平滑启动nginx,表示不停止nginx的情况下重启nginx
停止nginx:
- 完美停止nginx:
kill -QUIT
cat /var/run/nginx.pid`` - 快速停止nginx:
kill -INT
cat /var/run/nginx.pid`` - 完美停止工作进程,只要用作平滑升级:
kill -WINCH
cat /var/run/nginx.pid`` - 强制停止nginx:
pkill -9 nginx
- 停止ngix:
nginx -s stop
- 完美停止nginx: