Linux 系统下使用服务启动 Apache
来源:靑龍一笑的博客 作者:靑龍一笑 发布时间:2014-04-22 21:25:35 点击量:886 评论:0
一、编写服务脚本,把这个脚本放到 /etc/rc.d/init.d 目录下:
[root@RicenOS httpd-2.2.24]# vi /etc/rc.d/init.d/httpd
内容参考如下:
#!/bin/sh
#
# chkconfig:35 85 15
# description: Apache
#
case "$1" in
start)
echo "Starting Apache daemon ... "
/data/apache/bin/apachectl -k start
;;
stop)
echo "Stopping Apache daemon ... "
/data/apache/bin/apachectl -k stop
;;
restart)
echo "Restarting Apache daemon ... "
/data/apache/bin/apachectl -k restart
;;
*)
echo "Usage: $0 {start | stop | restart}"
exit 1
;;
esac
#
# chkconfig:35 85 15
# description: Apache
#
case "$1" in
start)
echo "Starting Apache daemon ... "
/data/apache/bin/apachectl -k start
;;
stop)
echo "Stopping Apache daemon ... "
/data/apache/bin/apachectl -k stop
;;
restart)
echo "Restarting Apache daemon ... "
/data/apache/bin/apachectl -k restart
;;
*)
echo "Usage: $0 {start | stop | restart}"
exit 1
;;
esac
二、改变文件权限:
[root@RicenOS httpd-2.2.24]# chmod +x /etc/rc.d/init.d/httpd
三、添加服务:
[root@RicenOS httpd-2.2.24]# chkconfig --level 35 httpd on
版权所有 © 2005-2023 靑龍一笑的博客 Powered by C.S.Ricen
Copyright © 2005-2023 by www.ricensoftwares.com.cn All Rights Reserved.
Copyright © 2005-2023 by www.ricensoftwares.com.cn All Rights Reserved.