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,如需转载请自行联系原作者

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值