vi /etc/init.d/nginx
#!/bin/sh
# nginx        Startup script for nginx
# chkconfig: - 85 15
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# description: nginx is an HTTP and reverse proxy server
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop nginx
### END INIT INFO
 
# Source function library.
. /etc/rc.d/init.d/functions
 
if [ -L $0 ]; then
    initscript=`/bin/readlink -f $0`
else
    initscript=$0
fi
 
sysconfig=`/bin/basename $initscript`
if [ -f /etc/sysconfig/$sysconfig ]; then
    . /etc/sysconfig/$sysconfig
fi
 
nginx=${NGINX-/usr/sbin/nginx}
prog=`/bin/basename $nginx`
conffile=${CONFFILE-/etc/nginx/nginx.conf}
lockfile=${LOCKFILE-/var/lock/subsys/nginx}
pidfile=${PIDFILE-/var/run/nginx.pid}
SLEEPMSEC=${SLEEPMSEC-200000}
UPGRADEWAITLOOPS=${UPGRADEWAITLOOPS-5}
RETVAL=0
 
start() {
    echo -n $"Starting $prog: "
 
    daemon --pidfile=${pidfile} ${nginx} -c ${conffile}
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch ${lockfile}
    return $RETVAL
}
 
stop() {
    echo -n $"Stopping $prog: "
    killproc -p ${pidfile} ${prog}
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
 
reload() {
    echo -n $"Reloading $prog: "
    killproc -p ${pidfile} ${prog} -HUP
    RETVAL=$?
    echo
}
 
upgrade() {
    oldbinpidfile=${pidfile}.oldbin
 
    configtest -q || return
    echo -n $"Starting new master $prog: "
    killproc -p ${pidfile} ${prog} -USR2
    echo
 
    for i in `/usr/bin/seq $UPGRADEWAITLOOPS`; do
        /bin/usleep $SLEEPMSEC
        if [ -f ${oldbinpidfile} -a -f ${pidfile} ]; then
            echo -n $"Graceful shutdown of old $prog: "
            killproc -p ${oldbinpidfile} ${prog} -QUIT
            RETVAL=$?
            echo
            return
        fi
    done
 
    echo $"Upgrade failed!"
    RETVAL=1
}
 
configtest() {
    if [ "$#" -ne 0 ] ; then
        case "$1" in
            -q)
                FLAG=$1
                ;;
            *)
                ;;
        esac
        shift
    fi
    ${nginx} -t -c ${conffile} $FLAG
    RETVAL=$?
    return $RETVAL
}
 
rh_status() {
    status -p ${pidfile} ${nginx}
}
 
# See how we were called.
case "$1" in
    start)
        rh_status >/dev/null 2>&1 && exit 0
        start
        ;;
    stop)
        stop
        ;;
    status)
        rh_status
        RETVAL=$?
        ;;
    restart)
        configtest -q || exit $RETVAL
        stop
        start
        ;;
    upgrade)
        rh_status >/dev/null 2>&1 || exit 0
        upgrade
        ;;
    condrestart|try-restart)
        if rh_status >/dev/null 2>&1; then
            stop
            start
        fi
        ;;
    force-reload|reload)
        reload
        ;;
    configtest)
        configtest
        ;;
    *)
        echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|upgrade|reload|status|help|configtest}"
        RETVAL=2
esac
 
exit $RETVAL
 
[root@node1 nginx]# chkconfig --add nginx
[root@node1 nginx]# /etc/init.d/nginx restart

Nginx的启动脚本的更多相关文章

  1. redhat nginx随机启动脚本

    开机自动启动nginx 1.    扔脚本进去/etc/init.d/ 2.    授权     chmod +x nginx 3.    一旦抛出:binsh^M错误就执行编码改写     设置do ...

  2. nginx 的启动脚本

    下载路径为: wget -q http://www.dwhd.org/script/Nginx-init-CentOS 根据自己的实际环境修改相应的参数 把该脚本放到/etc/rc.d/init.d/ ...

  3. Nginx的启动脚本(Centos)

    vim /etc/init.d/nginxservice nginx start #!/bin/sh # chkconfig: 2345 85 15 # description:Nginx Serve ...

  4. nginx-(/etc/init.d/nginx)启动脚本

    #!/bin/bash #nx Startup script for the Nginx HTTP Server # it is v. version. # chkconfig: - # descri ...

  5. Nginx服务启动脚本

    #!/bin/sh # chkconfig: 2345 40 98 # description: Start/Stop Nginx server path=/application/nginx/sbi ...

  6. Nginx的编译安装及服务启动脚本

    1.解决依赖关系 编译安装nginx需要事先需要安装开发包组"Development Tools"和 "Development Libraries".同时,还需 ...

  7. nginx、php-fpm启动脚本

    Nginx官方启动脚本 //service nginx stop|start|restart|reloadtouch /etc/init.d/nginx chmod nginxvi /etc/init ...

  8. nginx使用“sudo service nginx start”启动报错解决方案

    下载nginx的启动脚本: # wget -O init-deb.sh http://library.linode.com/assets/660-init-deb.sh 将脚本添加到init.d目录和 ...

  9. linux nginx 启动脚本

    linux nginx 启动脚本 [root@webtest76 ~]# vi /etc/init.d/nginx #!/bin/bash # nginx Startup script for the ...

随机推荐

  1. Python:常见错误集锦(持续更新ing)

    初学Python,很容易与各种错误不断的遭遇.通过集锦,可以快速的找到错误的原因和解决方法. 1.IndentationError:expected an indented block 说明此处需要缩 ...

  2. 高仿QQ即时聊天软件开发系列之一开端

    前段时间在园子里看到一个大神做了一个GG2014IM软件,仿QQ的,那感觉···,赶快下载源码过来试试,还真能直接跑起来,效果也不错.但一看源码,全都给封装到了ESFramework里面了,音视频那部 ...

  3. [置顶] chinayaosir近10年来所阅读的世界著名IT书籍-图文并茂

    1.人生观(包括做人原则,心理学,投资,销售) 一个人从来到世上,很多东西都是空白, 阅读一些正能量的书籍,把里面的理论用于生活,不断的应用它, 这些观念就会如同软件一样,不断的升级你的大脑, 合理的 ...

  4. Linux 软链接和硬链接的理解与学习

    理解前提: 首先要知道 Linux任意一个文件包含2个信息:第一个信息就是文件本身存的内容,第二个信息是文件的控制信息(读写,路径,大小等等),这2个信息是分开存储的,明白这点非常重要 理解总结: L ...

  5. css应用三

    1. Padding与margin Padding为内边距,padding值会计算在width和height之内.如:width:100px:height:100px:padding:10px:该di ...

  6. 从事web前端的这些日子

    不知不觉从事web前端快要一年了,在这一年的时间,自己的技术也得到了不小的进步,但毕竟还是停留在摸索的阶段,前端的这条路还有很长的路要走,前端要掌握的东西太多,知识也在频繁的更新.每天在群里和别人的交 ...

  7. new Handler()和new Handler(Looper.getMainLooper())的区别

    一个帖子的整理: Handler一定要在主线程实例化吗?new Handler()和new Handler(Looper.getMainLooper())的区别如果你不带参数的实例化:Handler ...

  8. Lintcode--011(打劫房屋2)

    在上次打劫完一条街道之后,窃贼又发现了一个新的可以打劫的地方,但这次所有的房子围成了一个圈,这就意味着第一间房子和最后一间房子是挨着的.每个房子都存放着特定金额的钱.你面临的唯一约束条件是:相邻的房子 ...

  9. Android4.0强制横屏竖屏

    Android的启动默认是横屏或者竖屏我们的TV本来是横屏显示,但是有客户竟然要竖屏显示,昨天快下班收到的需求,竟然说7.19就要搞定.思路有2个,一个就是修改LCD的默认输出,但是这个不是我这个水平 ...

  10. android slidingview

    http://blog.csdn.net/sky181772733/article/details/6969810 http://blog.csdn.net/ithomer/article/detai ...