linux环境启动nginx,linux环境停止和启动nginx

本文介绍了如何在Linux环境下管理Nginx服务。首先,通过`ps -ef | grep nginx`查询Nginx的主进程号。接着,使用`kill`命令配合不同的信号(QUIT、TERM或9)来优雅地停止或强制关闭Nginx。最后,展示了启动Nginx的命令,并验证了其工作状态。
摘要由CSDN通过智能技术生成

步骤1:查询nginx主进程号

ps -ef | grep nginx

在进程列表里 面找master进程,它的编号就是主进程号了。

步骤2:停止nginx

从容停止Nginx:

kill -QUIT 主进程号

快速停止Nginx:

kill -TERM 主进程号

强制停止Nginx:

pkill -9 nginx

步骤3:启动nginx

环境1:

[root@iZ25yepqfvvZ /]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

[root@iZ25yepqfvvZ /]# ps -ef | grep nginx

root 18798 1 0 16:35 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

root 18799 18798 0 16:35 ? 00:00:00 nginx: worker process

root 18800 18798 0 16:35 ? 00:00:00 nginx: worker process

root 18801 18798 0 16:35 ? 00:00:00 nginx: worker process

root 18802 18798 0 16:35 ? 00:00:00 nginx: worker process

root 18827 15138 0 16:36 pts/1 00:00:00 grep nginx

环境2

[root@iZ25yepqfvvZ /]# /usr/sbin/nginx -c /etc/nginx/nginx.conf

[root@iZ25knm9r1gZ ~]# ps -ef | grep nginx

root 28969 1 0 16:50 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf

nginx 28970 28969 0 16:50 ? 00:00:00 nginx: worker process

nginx 28971 28969 0 16:50 ? 00:00:00 nginx: worker process

nginx 28972 28969 0 16:50 ? 00:00:00 nginx: worker process

nginx 28974 28969 0 16:50 ? 00:00:00 nginx: worker process

root 29419 29401 0 17:11 pts/0 00:00:00 grep nginx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值