发布于 2016-12-03 21:04:03 | 124 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的Nginx开发从入门到精通,程序狗速度看过来!

Nginx WEB服务器

Nginx 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,第一个公开版本0.1.0发布于2004年10月4日。其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。


这篇文章主要介绍了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 (服务详细信息)

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务