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. linux命令帮助

    Linux命令格式:command [options] [arguments]command:命令options: 参数 [] 表示是可选的;<> 表示是可变化的; x|y|z 表示只能选 ...

  2. Jdbc 事务

    package com.j1; import java.sql.Connection; import java.sql.SQLException; import com.mysql.jdbc.Prep ...

  3. 获取checkboxlist选中的值以及绑定来自之前选中的来自数据库的值

    //////ps:一下几句都是一个意思,为的是以后有人搜索关键字的时候能定位到这里///checkboxlist绑定选中值///checkboxlist绑定来之mssql数据的值///checkbox ...

  4. Visual Studio 2015开发Android App问题集锦

    Visual Studio 2015开发Android App 启动调试始终无法完成应用部署的解决方案 创建一个Android App项目后,直接启动调试发现Visual Studio Emulato ...

  5. IActiveView 接口 - 浅谈

    IActiveView 和 IMap以其 Map, PageLayout之间的关系. 在ArcMap中, PageLayout 和 Map分别对应不同的视图: layout 和data view.在同 ...

  6. 树形dp hdu1561

    有的堡垒攻克需要攻克另一个堡垒,形成一个森林,最多攻克m个堡垒,求获得宝物的最大价值. 1,以0做根将森林形成树: 2,用背包计算当前节点下需要攻克k个堡垒能获得的宝物最大价值,但是注意同一个根节点的 ...

  7. 《Boost程序库完全开发指南》读书笔记-日期时间

    ●timer库 #include <boost\timer.hpp> #include <boost\progress.hpp> 1.timer类 // timer类的示例. ...

  8. mysql 5.6 参数详解

    系统变量提供的是各种与服务器配置和功能有关的信息.大部分的系统变量都可以在服务器启动时进行设置.在运行时,每一个系统变量都拥有一个全局值或会话值,或者同时拥有这两个值.许多系统变量都是动态的,也就是说 ...

  9. 各种位置和高度计算:.position()、.offset()、.outerHeight()、.scrollTop、.scrollHeight、.clientHeight

    1..position()和.offset() jquery的.position()获取相对于最近的position为relative或absolute的父元素的偏移,返回.position().le ...

  10. 使用PowerDesigner 15对现有数据库进行反向工程(图解教程)

    1.启动PD 2.菜单:File->Reverse Engineer ->Database 出来New Physical Data Model对话框 点击“确定”按钮,弹出Database ...