admin avatar

注册nginx的systemctl服务

🕓 by admin

注册nginx的systemctl服务

方便管理和使用,,,

vi /lib/systemd/system/nginx.service

添加以下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
[Unit]
Description=nginx
After=network.target

[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

常用命令

1
2
3
4
5
systemctl start nginx.service    //启动nginx服务
systemctl stop nginx.service     //关闭nginx服务
systemctl restart nginx.service   //重启nginx服务
systemctl reload snginx.service    //重新加载nginx配置文件
systemctl status nginx.service    //查看nginx服务状态

💘 相关文章

写一条评论