nginx源码编译后启动脚本

简介:

nginx源码编译后启动脚本

 

 
  1. #!/bin/sh 
  2. # nginx - this script starts and stops the nginx daemin 
  3. # chkconfig:   - 85 15 
  4. # description:  Nginx is an HTTP(S) server, HTTP(S) reverse \ 
  5. #               proxy and IMAP/POP3 proxy server 
  6. # processname: nginx 
  7. # config:      /usr/local/nginx/conf/nginx.conf 
  8. # pidfile:     /usr/local/nginx/logs/nginx.pid 
  9.  
  10. # Source function library. 
  11. . /etc/rc.d/init.d/functions 
  12.  
  13. # Source networking configuration. 
  14. . /etc/sysconfig/network 
  15.  
  16. Check that networking is up. 
  17. "$NETWORKING" = "no" ] && exit 0 
  18.  
  19. nginx="/usr/local/nginx/sbin/nginx" 
  20. prog=$(basename $nginx) 
  21.  
  22. NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" 
  23.  
  24. lockfile=/var/lock/subsys/nginx 
  25.  
  26. start() { 
  27.     [ -x $nginx ] || exit 5 
  28.     [ -f $NGINX_CONF_FILE ] || exit 6 
  29.     echo -n $"Starting $prog: " 
  30.     daemon $nginx -c $NGINX_CONF_FILE 
  31.     retval=$? 
  32.     echo 
  33.     [ $retval -eq 0 ] && touch $lockfile 
  34.     return $retval 
  35.  
  36. stop() { 
  37.     echo -n $"Stopping $prog: " 
  38.     killproc $prog -QUIT 
  39.     retval=$? 
  40.     echo 
  41.     [ $retval -eq 0 ] && rm -f $lockfile 
  42.     return $retval 
  43.  
  44. restart() { 
  45.     configtest || return $? 
  46.     stop 
  47.     start 
  48.  
  49. reload() { 
  50.     configtest || return $? 
  51.     echo -n $"Reloading $prog: " 
  52.     killproc $nginx -HUP 
  53.     RETVAL=$? 
  54.     echo 
  55.  
  56. force_reload() { 
  57.     restart 
  58.  
  59. configtest() { 
  60.   $nginx -t -c $NGINX_CONF_FILE 
  61.  
  62. rh_status() { 
  63.     status $prog 
  64.  
  65. rh_status_q() { 
  66.     rh_status >/dev/null 2>&1 
  67.  
  68. case "$1" in 
  69.     start) 
  70.         rh_status_q && exit 0 
  71.         $1 
  72.         ;; 
  73.     stop) 
  74.         rh_status_q || exit 0 
  75.         $1 
  76.         ;; 
  77.     restart|configtest) 
  78.         $1 
  79.         ;; 
  80.     reload) 
  81.         rh_status_q || exit 7 
  82.         $1 
  83.         ;; 
  84.     force-reload) 
  85.         force_reload 
  86.         ;; 
  87.     status) 
  88.         rh_status 
  89.         ;; 
  90.     condrestart|try-restart) 
  91.         rh_status_q || exit 0 
  92.             ;; 
  93.     *) 
  94.         echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" 
  95.         exit 2 
  96. esac 

 本文转自dongfang_09859 51CTO博客,原文链接:http://blog.51cto.com/hellosa/502924,如需转载请自行联系原作者

相关文章
|
16天前
|
应用服务中间件 Linux 网络安全
CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本
CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本
15 0
|
3月前
|
应用服务中间件 Shell 开发工具
nginx+shell脚本实现一键启用与关闭停机维护页面
nginx+shell脚本实现一键启用与关闭停机维护页面
33 0
|
7月前
|
Ubuntu 应用服务中间件 Shell
用shell脚本部署nginx
用shell脚本部署nginx
109 2
|
3月前
|
算法 应用服务中间件 nginx
NGINX下的红黑树源码详解(附 流程图和GIF)(1)
之前博主稍微讲解了下红黑树的原理,那么在这篇博客博主想要把红黑树讲的更加的透彻,以便于更多的人了解红黑树 (本博客会更加详细的介绍之前的博客没介绍到的,所以各位看官不同再回去翻看博主之前那篇红黑树的原理讲解了。)
39 3
|
2月前
|
运维 应用服务中间件 Shell
Nginx安装与虚拟主机配置shell脚本
Nginx安装与虚拟主机配置shell脚本
28 0
|
3月前
|
应用服务中间件 nginx
Nginx源码阅读:共享内存ngx_shm_t和它的组织方式ngx_shm_zone_t、ngx_list_t
Nginx源码阅读:共享内存ngx_shm_t和它的组织方式ngx_shm_zone_t、ngx_list_t
24 0
|
3月前
|
应用服务中间件 nginx
Nginx源码阅读:ngx_list_t 链表
Nginx源码阅读:ngx_list_t 链表
52 0
|
3月前
|
存储 应用服务中间件 nginx
Nginx模块开发:模块结构的源码阅读以及过滤器(Filter)模块的实现
Nginx模块开发:模块结构的源码阅读以及过滤器(Filter)模块的实现
65 0
|
3月前
|
算法 应用服务中间件 nginx
NGINX下的红黑树源码详解(附 流程图和GIF)(2)
那我们就接着之前的gif继续吧 涉及到的 3/4、5情况(精简版) 情况3:变化前[当前结点为4节点]: 当前节点的父节点是红色且祖父节点的另一个子节点(叔叔节点)是红色。
22 2
|
4月前
|
应用服务中间件 Linux 网络安全
源码方式安装nginx及其依赖并设置服务开机启动
源码方式安装nginx及其依赖并设置服务开机启动
115 0