大旗谷资源网 Design By www.zqyou.com

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 $"htmlcode">
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 

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

标签:
CentOS6.3添加nginx系统服务,CentOS添加nginx系统服务的方法

大旗谷资源网 Design By www.zqyou.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
大旗谷资源网 Design By www.zqyou.com

评论“CentOS6.3添加nginx系统服务的实例详解”

暂无CentOS6.3添加nginx系统服务的实例详解的评论...

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。

更新日志