Chinaunix首页 | 论坛 | 博客
  • 博客访问: 26187911
  • 博文数量: 2065
  • 博客积分: 10377
  • 博客等级: 上将
  • 技术积分: 21525
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-04 17:50
文章分类

全部博文(2065)

文章存档

2012年(2)

2011年(19)

2010年(1160)

2009年(969)

2008年(153)

分类: 系统运维

2010-08-24 16:27:45

#!/bin/sh
# 将脚本保存为/etc/rc.d/init.d/nginxd,便可以使用service命令启动、停止、重启nginx服务。service nginxd restart
# 启动nginx 命令./nginxd start  关闭./nginxd stop 重启 ./nginxd restart
# source function library
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

RETVAL=0
prog="nginx"

nginxDir=/usr/local/nginx            #视安装路径而作修改
nginxd=$nginxDir/sbin/nginx
nginxConf=$nginxDir/conf/nginx.conf
nginxPid=$nginxDir/nginx.pid

start()
{
        if [[ -e $nginxPid ]]; then
                echo "$prog already running..."
                exit 1
        else
                echo -n $"Starting $prog:"
                daemon $nginxd -c $nginxConf
                RETVAL=$?
                echo
                [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
                return $RETVAL
        fi
}

stop()
{
        echo -n $"Stopping $prog:"
        killproc $nginxd

        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx $nginxPid
}

reload()
{
        echo -n $"Reloading $prog:"
        killproc $nginxd -HUP
        RETVAL=$?
        echo
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                stop
                start
                ;;
        reload)
                reload
                ;;
        status)
                status $prog
                RETVAL=$?
                ;;
        *)
                echo $"Usage: $0 {start|stop|restart|reload|status}"
                RETVAL=1
esac
exit $RETVAL
阅读(840) | 评论(0) | 转发(0) |
0

上一篇:ntpdate 命令

下一篇:聚合端口概念

给主人留下些什么吧!~~