nginx centos 服务开机启动设置实例详解
linux  /  管理员 发布于 7年前   149
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 (服务详细信息)
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..路人 在
php中使用hyperf框架调用讯飞星火大模型实现国内版chatgpt功能示例中评论 教程很详细,如果加个前端chatgpt对话页面就完美了..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号