nginx centos 服务开机启动设置
建立服务文件
以nginx 为例
vim /lib/systemd/system/nginx.service
在nginx.service 中插入一下内容
[Unit] Description=nginx After=network.target [Service] Type=forking ExecStart= 服务启动命令 ExecReload= 服务重启命令 ExecStop=服务停止命令 PrivateTmp=true [Install] WantedBy=multi-user.target
[Unit]:服务的说明
Description:描述服务
After:描述服务类别
[Service]服务运行参数的设置
Type=forking是后台运行的形式
ExecStart为服务的具体运行命令
ExecReload为重启命令
ExecStop为停止命令
PrivateTmp=True表示给服务分配独立的临时空间
注意:[Service]的启动、重启、停止命令全部要求使用绝对路径
以754的权限保存在目录:/lib/systemd/system
设置开机自启动:
systemctl enable nginx.service
相关命令
功能 cnetos7以前 cnetos7
显示所有已启动的服务 chkconfig --list systemctl list-units --type=service
启动某服务 service nginx start systemctl start nginx.service 或 systemctl start nginx
停止某服务 service nginx stop systemctl stop nginx.service 或 systemctl stop nginx
重启某服务 service nginx restart systemctl restart nginx.service 或 systemctl restart nginx
使某服务自动启动 chkconfig --level 3 nginx on systemctl enable nginx.service 或 systemctl enable nginx
使某服务不自动启动 chkconfig --level 3 nginx off systemctl disable nginx.service 或 systemctl disable nginx
检查服务状态 service nginx status systemctl is-active nginx.service (仅显示是否)Activesystemctl status nginx.service (服务详细信息)
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
更新日志
- 《绝对主打 流行原创金曲 2CD》[WAV分轨][1.1GB]
- 《赛博朋克2077》更新上线:支持AMD FSR3
- 《塞尔达传说:智慧的再现》提前半个月偷跑,引发玩家担忧
- 战锤40K星际战士2全职业介绍|全职业技能效果一览
- 陈百强《2006世纪10星·永恒篇[环球]》[WAV整轨]
- 【新世纪钢琴】VA-GoldenOctober(Piano)(金秋十月钢琴篇)【FLAC】
- 青稞荞麦《破茧》新生代组合[WAV+CUE]
- 因系统升级后出现BUG 《FF16》PS5完全版宣布延期
- 《黑神话:悟空》周伯通!大佬用左右手分别挑战两只虎先锋
- 《黑神话:悟空》攻击动作致敬《大话西游》:这也太帅了!
- 《星舰铳犬太阳系物语》游戏背景介绍
- 《战锤40K星际战士2》终极版有后续DLC说明
- 《第9层》游戏特色玩法介绍
- 刀郎.2006-刀郎【九雨天下】【WAV+CUE】
- 59.9高校生.1994-素兰万岁【上华】【WAV+CUE】