1 Nginx启动

#关闭防火墙,系统重启后还会启动
[root@node1 ~]# systemctl stop firewalld
[root@node1 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)

#禁用防火墙,系统重启后
[root@node1 ~]# systemctl disable firewalld
[root@node1 ~]# systemctl list-unit-files |grep firewalld
firewalld.service disabled

启动Nginx:运行sbin目录下的nginx命令即可。

[root@node1 ~]# cd /usr/local/nginx/sbin/
[root@node1 sbin]# ls
nginx
[root@node1 sbin]# ./nginx
[root@node1 sbin]# ps aux|grep nginx
root 46423 0.0 0.0 40884 800 ? Ss 16:13 0:00 nginx: master process ./nginx
nobody 46424 0.0 0.5 73964 4244 ? S 16:13 0:00 nginx: worker process
root 46426 0.0 0.1 12344 1152 pts/4 S+ 16:13 0:00 grep --color=auto nginx

测试:http://192.168.20.101
Nginx启动与关闭_杀死进程

2 关闭Nginx

立即停止服务
这种方法比较强硬,无论进程是否在工作,都直接停止进程。

[root@node1 sbin]# ./nginx -s stop
[root@node1 sbin]# ps aux|grep nginx
root 25496 0.0 0.0 112824 980 pts/0 S+ 16:44 0:00 grep --color=auto nginx

.killall 方法杀死进程
直接杀死进程,在上面无效的情况下使用,态度强硬,简单粗暴!

[root@node1 sbin]# ./nginx 
[root@node1 sbin]# ps aux|grep nginx
root 25482 0.0 0.1 45996 1132 ? Ss 16:44 0:00 nginx: master process ./nginx
nobody 25483 0.0 0.1 46444 1872 ? S 16:44 0:00 nginx: worker process
root 25496 0.0 0.0 112824 980 pts/0 S+ 16:44 0:00 grep --color=auto nginx
[root@node1 sbin]# killall nginx
[root@node1 sbin]# ps aux|grep nginx
root 25574 0.0 0.0 112824 984 pts/0 S+ 16:46 0:00 grep --color=auto nginx