发布于 2017-10-30 13:07:01 | 172 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的Nginx中文文档,程序狗速度看过来!

Nginx WEB服务器

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


这篇文章主要介绍了CentOS6.3添加nginx系统服务的实例详解的相关资料,希望通过本文能帮助到大家,让大家掌握这部分内容,需要的朋友可以参考下

CentOS6.3添加nginx系统服务的实例详解

前言:

今天虚拟机上配了下服务器整理了个这个 nginx 服务

要注意 - 短横杠这个符号看看复制进去后有没有乱码,我之前就遇到这个问题,郁闷了好久才发现

提示:顶部的注释不要去除否则无法注册为系统服务,

关于:chkconfig: 2345 65 37

网上搜索总结了下意思是:

  • 2345 为启动该服务的系统环境
  • 65   为加载的优先级别
  • 37   为关闭的优先级别

65,37 这两个位置的数值不能相同,也不能和其它服务的数值冲突,这个我也没遇到过此类问题,如果有发现问题请对应自己的配置修改下好了

新建文件:


# vi /etc/init.d/nginx 

输入内容:


#!/bin/sh 
# Comments to support chkconfig on RedHat Linux 
# chkconfig: 2345 65 37 
# description: A nginx daemon. 
                         
set -e 
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 
DESC="nginx daemon" 
NAME=nginx 
DAEMON=/usr/local/nginx/sbin/$NAME 
SCRIPTNAME=/etc/init.d/$NAME 
                         
# If the daemon file is not found, terminate the script. 
test -x $DAEMON || exit 0 
                         
d_test() { 
  $DAEMON -t 
} 
d_start() { 
  $DAEMON || echo -n " already running" 
} 
d_stop() { 
  $DAEMON -s quit || echo -n " not running" 
} 
d_reload() { 
  $DAEMON -s reload || echo -n " could not reload" 
} 
                         
case "$1" in 
  test) 
   d_test 
   echo "." 
   ;; 
  start) 
   echo -n "Starting $DESC: $NAME" 
   d_start 
   echo "." 
   ;; 
  stop) 
   echo -n "Stopping $DESC: $NAME" 
   d_stop 
   echo "." 
   ;; 
  reload) 
   echo -n "Reloading $DESC configuration..." 
   d_reload 
   echo "reloaded." 
   ;; 
  restart) 
   echo -n "Restarting $DESC: $NAME" 
   d_stop 
   # Sleep for two seconds before starting again, this should give the 
   # Nginx daemon some time to perform a graceful stop. 
   sleep 2 
   d_start 
   echo "." 
   ;; 
  *) 
   echo "Usage: $SCRIPTNAME {test|start|stop|restart|reload}" >&2 
   exit 3 
   ;; 
esac 
                         
exit $? 

注册 nginx 服务:


chmod +x /etc/init.d/nginx 
chkconfig --add nginx 
chkconfig --level 2345 nginx on 
chkconfig --list nginx 

相关 nginx 命令:

检测 nginx 配置


# service nginx test 

启动


# service nginx start 

关闭


# service nginx stop 

重启


# service nginx restart 

重载配置


# service nginx reload 

如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!



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

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