Chinaunix首页 | 论坛 | 博客
  • 博客访问: 805724
  • 博文数量: 94
  • 博客积分: 1767
  • 博客等级: 上尉
  • 技术积分: 1168
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-13 23:16
个人简介

ha

文章分类

全部博文(94)

文章存档

2014年(2)

2013年(17)

2012年(6)

2011年(15)

2010年(23)

2009年(23)

2008年(8)

我的朋友

分类: LINUX

2009-09-21 14:39:21

我放在/etc/init.d目录下的apache服务脚本httpd在执行chkconfig --add httpd时出现错误:
“service httpd does not support chkconfig

网上搜了一会儿,原来是这样,每个服务脚本的开头的几行里都会有给chkconfig用的注释。表明一些chkconfig用的信息,具体格式可以man chkconfig一下。

比如我后来在httpd文件的开头加入了一下几行,就可以了(看头几个注释行就行了,后面的大家都知道,呵呵): 

#!/bin/sh 

# Startup script for the Apache Web Server 

# chkconfig: 345 85 15 (这个比较有意思,345代表在设置在那个level中是on的,如果一个都不想on,那就写一个横线"-",比如:chkconfig: - 85 15。后面两个数字当然代表S和K的默认排序号啦)
# description: Apache is a World Wide Web server.  It is used to serve \ 
#              HTML files and CGI. 
# processname: httpd 
# pidfile: /var/run/httpd.pid 
# config: /usr/local/apache2/conf/httpd.conf (我装东西比较喜欢都放在/usr/local下)
 
# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/httpd ]; then
       . /etc/sysconfig/httpd
fi

INITLOG_ARGS=""

apachectl=/usr/local/apache2/bin/apachectl
httpd=${HTTPD-/usr/local/apache2/bin/httpd}

prog="httpd"

start()
{
    ps -ef | grep "$prog" | grep -v "grep" | grep -v "start" > /dev/null
    if [ "$?" -eq "1" ]; then
        echo -n $"Starting $prog: "
        daemon $httpd $OPTIONS
        ret=$?
        echo
        [ "$ret" -eq "0" ] && touch /var/lock/subsys/httpd
        return 0
    else
        echo "httpd running"
        return 0
    fi
}

stop()
{
    status httpd >/dev/null >&1
    ret_status=$?
    if [ $ret_status -eq 2 ]; then
        rm -f /var/lock/subsys/httpd /var/run/httpd.pid
        echo "httpd stopped"
        return 0
    elif [ $ret_status -eq 3 ]; then
        echo "httpd stopped"
        return 0
    fi
    echo -n $"Stopping $prog: "
    killproc $httpd
    ret=$?
    echo
    [ "$ret" -eq "0" ] && rm -f /var/lock/subsys/httpd /var/run/httpd.pid
    return 0
}

case "$1" in
    start)
       start
       ;;
    stop)
       stop
       ;;
    status)
       status httpd
       ;;
    restart)
       stop
       sleep 2
       start
       ;;
    *)
       echo $"Usage: $prog {start|stop|restart|status}"
       exit 1
esac
阅读(3122) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~