nginx centos 服务开机启动设置实例详解
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 (服务详细信息)
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
相关文章
Nginx反向代理location和proxy_pass配置规则详细总结
nginx代理访问很好用,但是好多人不清楚location和proxy_pass组合在一起使用时访问的url被代理的url真实地址是什么,下面这篇文章主要给大家介绍了关于Nginx反向代理location和proxy_pass配置规则的相关资料,需要的朋友可以参考下2022-09-09将树莓派转身为强大的Web服务器如何使用Nginx和cpolar实现远程访问
这篇文章主要介绍了Nginx可视化管理工具结合cpolar实现远程访问内网服务,相比其他 Web 服务器,Nginx 的内存占用率非常低,可以在树莓派等资源受限的设备上运行,同时结合cpolar 内网穿透工具即可实现远程访问,需要的朋友可以参考下2023-09-09结合 Nginx 将 DoNetCore 部署到 阿里云的安装配置方法
这篇文章主要介绍了结合 Nginx 将 DoNetCore 部署到 阿里云的方法 ,需要的朋友可以参考下2018-10-10Nginx安装后/etc/nginx/conf.d下没有default.conf的解决
nginx.conf是nginx默认加载的配置文件 通过nginx -V可以看nginx默认配置文件路径,本文主要介绍了Nginx安装后/etc/nginx/conf.d下没有default.conf的解决,感兴趣的可以了解一下2023-11-11ConfigMap挂载与Subpath在Nginx容器中的应用小结
configmap可以通过ENV环境变量和文件两种方式挂载到容器中,修改configmap后容器中对应的ENV环境变量不会更新,将配置文件nginx.conf以configmap文件的方式挂载到容器中,本文介绍ConfigMap挂载与Subpath在Nginx容器中的应用小结,感兴趣的朋友一起看看吧2024-03-03
最新评论