nginx

关注公众号 jb51net

关闭
首页 > 网站技巧 > 服务器 > nginx > 使用systemctl方式管理nginx

使用systemctl方式管理nginx方式

作者:肥美怪叫兔

这篇文章主要介绍了使用systemctl方式管理nginx方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教

1.源码安装的nginx

不能使用systemctl方式进行管理,所以需要创建配置文件

vim /usr/lib/systemd/system/nginx.service

2.写入以下内容

[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID

[Install]
WantedBy=multi-user.target

3.重载配置文件

systemctl daemon-reload

然后就可以使用systemctl方式管理nginx啦

systemctl start nginx
systemctl status nginx
systemctl stop nginx

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:
阅读全文