nginx的启动,重启,关闭
2019-03-18 本文已影响0人
一个被程序员耽误的厨师
nginx启动,在终端输入:
ps -ef|grep nginx
如果执行结果是这样的,说明已经启动:
xianmindeMacBook-Pro:nginx daweikeji$ ps -ef|grep nginx
0 31888 1 0 9:41上午 ?? 0:00.01 nginx: master process nginx
0 32088 31888 0 10:05上午 ?? 0:00.01 nginx: worker process
502 32863 32740 0 1:17下午 ttys000 0:00.00 grep nginx
如果执行结果是这样的,说明还没有启动:
xianmindeMacBook-Pro:nginx daweikeji$ ps -ef|grep nginx
502 32881 32740 0 1:24下午 ttys000 0:00.00 grep nginx
启动命令,在终端输入:
sudo nginx -s reload
注意这里如果报错信息如下:

解决方法如下:
1.在终端输入:
sudo nginx -c /usr/local/etc/nginx/nginx.conf
2.在终端输入:
sudo nginx -s reload
3.检查是否中期成功:浏览器输入http://localhost:8080/

nginx的关闭
在中输入:ps -ef|grep nginx
获取到nginx的进程号,注意是找到“nginx:master”的那个进程号
ps -ef|grep nginx
$ ps -ef|grep nginx
0 32912 1 0 1:35下午 ?? 0:00.00 nginx: master process nginx -c /usr/local/etc/nginx/nginx.conf
-2 32913 32912 0 1:35下午 ?? 0:00.00 nginx: worker process
502 32921 32740 0 1:43下午 ttys000
在终端再输入要停止的县城就可以了
kill -QUIT 15800 (从容的停止,即不会立刻停止)
Kill -TERM 15800 (立刻停止)
Kill -INT 15800 (和上面一样,也是立刻停止)