首页 > 其他 > 详细

centos7 nginx 启动脚本

时间:2020-10-13 17:31:08      阅读:36      评论:0      收藏:0      [点我收藏+]
[root@localhost ~]# vim /lib/systemd/system/nginx.service
[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
#EnvironmentFile=/etc/sysconfig/rdisc
#ExecStart=/sbin/rdisc $RDISCOPTS
 
[Install]
WantedBy=multi-user.target
[Unit]:服务的说明
Description:描述服务
After:描述服务类别
[Service]服务运行参数的设置
Type=forking是后台运行的形式
ExecStart为服务的具体运行命令
ExecReload为重启命令
ExecStop为停止命令
PrivateTmp=True表示给服务分配独立的临时空间
注意:[Service]的启动、重启、停止命令全部要求使用绝对路径
[Install]运行级别下服务安装的相关设置,可设置为多用户,即系统运行级别为3
# 设置开机启动
[root@localhost ~]# systemctl enable nginx
 
# 停止开机自动启动
[root@localhost ~]# systemctl disable nginx
 
# 启动nginx服务
[root@localhost ~]# systemctl start nginx
 
# 查看服务当前状态
[root@localhost ~]# systemctl status nginx
 
# 重启nginx服务
[root@localhost ~]# systemctl restart nginx.service
 
 
# 查看所有已经启动的服务
[root@localhost ~]# systemctl list-units --type=service

centos7 nginx 启动脚本

原文:https://www.cnblogs.com/CGCong/p/13809633.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!