![]() |
LINUX |
httpd起動スクリプト
・httpd-2.2.20を自動起動するスクリプトです
・ソースに含まれるhttpd.initをリネームして使用します
・完全コピーしないこと (エラーが出ることあり)
・"#" で始まる行はコメントとして解釈され、"$" の付いた文字は変数を表します
・スクリプトの先頭で, 処理を行うシェルを明示します (#!/bin/bash)
・# chkconfig: の#のあとに半角スペース
・# description: の#のあとに半角スペース
・. / . はファイルを読み込むコマンド 後に半角スペース
・[ ] はテストコマンドです 半角スペースを忘れないように
・[ = ] テストコマンド内は = の前後に半角スペース
・環境変数等価式=の場合、前後に半角スペースをいれない
・A && B Aが正ならばBを実効
・A || B Aが為ならばBを実効
・$0 はスクリプト本体 $1は 第1引数
・ユーザ・オーナー・パーミッション (root root 755)
/etc/rc.d/init.d/httpd
#!/bin/bash
#
# Startup script for the Apache Web Server
#
# chkconfig: 235 85 15
# 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: /etc/httpd/conf/httpd.conf
# Source function library. . /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi
# This will prevent initlog from swallowing up a pass-phrase prompt if # mod_ssl needs a pass-phrase from the user. INITLOG_ARGS=""
# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server # with the thread-based "worker" MPM; BE WARNED that some modules may not # work correctly with a thread-based MPM; notably PHP will refuse to start.
# Path to the apachectl script, server binary, and short-form for messages.
PATH=$PATH:/usr/local/apache2/bin
prog=httpd
RETVAL=0
start() {
echo -n $"Starting $prog: "
daemon httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /var/run/httpd.pid
}
reload() {
echo -n $"Reloading $prog: "
killproc httpd -HUP
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/run/httpd.pid ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|\
reload|status|graceful|fullstatus|help|configtest}"
exit 1
esac
exit $RETVAL
![]() |
Copyright(c) 528p.com All Rights Reserved. |

