设置开机自启动
ystemctl enable nginx.service
停止开机自启动
systemctl disable nginx.service
查看当前状态
systemctl status nginx.service
查看所有已启动的服务
systemctl list-units --type=service
查看
ps -ef|grep nginx
第一种方式
启动:代码格式:nginx安装目录地址 -c nginx配置文件地址
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
systemctl start nginx.service
停止
kill -QUIT 进程号
kill -TERM 进程号
kill -INT 进程号
强制停止 pkill -9 nginx
systemctl stop nginx.service
验证
方法一:进入nginx安装目录sbin下,输入命令./nginx -t
方法二:在启动命令-c前加-t
2、重启
方法一:进入nginx可执行目录sbin下,输入命令
./nginx -s reload
systemctl restart nginx.service
方法二:查找当前nginx进程号,然后输入命令:
kill -HUP 进程号