百度空间 | 百度首页 
 
查看文章
 
配置在linux下apache自动启动的脚本
2008-04-23 12:32

当手动编译安装apache服务器后一般不会开机自动运行,需要自己添加:

# cd /etc/init.d
# vi apache2

加上以下脚本

#!/bin/sh
# description: Apache auto start-stop script.
# chkconfig: - 85 15

APACHE_HOME=/usr/local/apache2
APACHE_OWNER=root
if [ ! -f "$APACHE_HOME/bin/apachectl" ]
then
    echo "Apache startup: cannot start"
    exit
fi
case "$1" in
    'start')
        su - $APACHE_OWNER -c "$APACHE_HOME/bin/apachectl start"
        ;;
    'stop')
        su - $APACHE_OWNER -c "$APACHE_HOME/bin/apachectl stop"
        ;;
    'restart')
        su - $APACHE_OWNER -c "$APACHE_HOME/bin/apachectl restart"
        ;;
esac

# chmod 755 apache
# chkconfig --add apache
# chkconfig --level 345 apache2 on

Ok,测试Apache
# service apache2 start
# service apache2 stop
# service apache2 restart

同时reboot OS试一下apache是否开机自动运行了。


类别:Linux | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu