nginx 启动脚本 for suse

本文介绍了一个用于管理Nginx服务的bash脚本,包括启动、停止、重启及重新加载配置等功能,并展示了如何设置Nginx在系统启动时自动运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



#!/bin/bash



# init.d/nginx
#
#   and symbolic its link
#
# /usr/local/nginx/sbin/nginx
#
# System startup script for the nginx daemon
#
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: no
# Required-Stop:  no
# Should-Start: no
# Should-Stop:  no
# Default-Start:  3 5
# Default-Stop:   0 1 2 6
# Description:    Start the nginx server daemon
### END INIT INFO


. /etc/rc.status


rc_reset
NGINX_BIN=/usr/local/nginx/sbin/nginx
NGINX_PID_FILE=/var/run/nginx.pid


function nginx_start {
    echo -n "Starting nginx daemon"
     startproc  -p $NGINX_PID_FILE -t 1 $NGINX_BIN
     rc_status -v
}




function nginx_stop {
     echo -n "Shutting down nginx daemon"
    killproc -p $NGINX_PID_FILE -TERM $NGINX_BIN
    rc_status -v
}


function nginx_reload {
     echo -n "Reload service rsync"
  killproc -p $NGINX_PID_FILE -HUP $NGINX_BIN
  rc_status -v


}
case $1 in 
  start)
       nginx_start
;;


  stop)
      nginx_stop
;;
 
  restart)
        nginx_stop
        nginx_start
;;
  reload)
   nginx_reload
;;
  *)
   echo  "Useage  $0 start|stop|restart|reload "
;;

esac


设置35极别开机启动

DJFW-web01:/etc/init.d # ln -sf /etc/init.d/nginx /etc/rc.d/rc3.d/S22nginx
DJFW-web01:/etc/init.d # ln -sf /etc/init.d/nginx /etc/rc.d/rc3.d/K22nginx
DJFW-web01:/etc/init.d # ln -sf /etc/init.d/nginx /etc/rc.d/rc5.d/K22nginx
DJFW-web01:/etc/init.d # ln -sf /etc/init.d/nginx /etc/rc.d/rc5.d/S22nginx

22:查看/etc/rc.d/rc3.d/目录最后一位数字,再向后加就可以了。

DJFW-web01:/etc/init.d # chkconfig --list | grep nginx
nginx                     0:off  1:off  2:off  3:on   4:off  5:on   6:off



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值