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 (服务详细信息)
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
更新日志
- [雨果唱片]李冰《地方民歌·戏曲系列-爱的颂歌》WAV
- 《模拟人生》真人电影官宣!玛格特·罗比担任制片人
- 《星战绝地》系列玩家数超4000万!续作表现超预期
- EA称AI是其业务核心!能提高开发效率、节约成本
- 《十年经典成名好歌 高品质最佳音乐 2CD》[WAV/分轨][1GB]
- 《8个男人的故事 2CD》[WAV/分轨][1GB]
- 《粤语超白金 百听不厌的经典金曲 2CD》[WAV/分轨][1.3GB]
- 群星.1994-全世界精丫华星】【WAV+CUE】
- 杜德伟.1997-知.解2CD【滚石】【WAV+CUE】
- 群星.2022-一不小心喵上你原声大碟【TME影音】【FLAC分轨】
- 《战锤40K星际战士2》卡在正在加入服务器解决方法
- 《勇者斗恶龙怪物仙境3》玩法内容介绍
- 《幸福工厂》无限报错解决方法
- 交错战线原始交易所推荐角色一览
- 战锤40K星际战士2战术职业介绍|战术职业技能效果一览