Linux Centos7 设置Nginx开机自启动

新建vi /lib/systemd/system/nginx.service在nginx.service文件

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true

[Install]
WantedBy=multi-user.target

启动nginx服务

systemctl start nginx.service

设置开机自启动nginx服务

systemctl enable nginx.service

停止开机自启动nginx服务

systemctl disable nginx.service

查看当前服务状态

systemctl status nginx.service

扫描二维码关注公众号,回复: 115933 查看本文章

重新启动服务

systemctl restart nginx.service

查看所有已启动的服务

systemctl list-units --type=service

猜你喜欢

转载自www.cnblogs.com/wusheng2016/p/8998030.html