源码包http启动脚本,仅供参考......下面有文本的。
#!/bin/bash
#Author: wangergui Email:291131893@qq.com Date:2016-06-01
#Function: source apache start script
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root:/bin
export PATH
[ -f /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions || exit 2
APACHE=/usr/local/apache2/bin/apachectl
PIDFILE=/usr/local/apache2/logs/httpd.pid
CODE=$(curl -I -s http://localhost |awk 'NR==1 {print $2}')
function mystart () {
if [ ${CODE} -eq 200 -a -f ${PIDFILE} ];then
echo " httpd is aready running!"
else
rm -rf ${PIDFILE} && ${APACHE} && [ $? -eq 0 ] && echo "httpd start sucellfully!" || exit 3
fi
}
function mystop () {
wget -q http://localhost >/dev/null 2>&1
if [ $? -eq 0 -a -f ${PIDFILE} ];then
killall -9 httpd
[ $? -eq 0 ] && echo "httpd stop ok"
else
rm -rf ${PIDFILE} && echo "httpd stop failed!"
fi
}
function myrestart () {
mystart
sleep 2
mystop
}
function myreload () {
wget -q http://localhost >/dev/null 2>&1
[ $? -eq 0 -f ${PIDFILE} ] && killall -s HUP ${APACHE} || exit 4
[ $? -ne 0 ] && echo "httpd service is not starting!"
}
function mystatus () {
wget -q http://localhost >/dev/null 2>&1
[ $? -eq 0 -a -f ${PIDFILE} ] && echo "httpd is running" || echo "httpd stop"
}
case $1 in
"start")
mystart
;;
"stop")
mystop
;;
"restart")
myrestart
;;
"reload")
myreload
;;
"status")
mystatus
;;
"*")
echo $"Usage: $0 {start|stop|restart|reload|status|}"
exit 8
;;
esac
本文转自 wangergui 51CTO博客,原文链接:http://blog.51cto.com/wangergui/1834888,如需转载请自行联系原作者