#contents

*はじめに [#hf9be13b]
いつも再起動後に、apachectlを叩くのは面倒なので、自動起動のスクリプトを用意します。

*rc.localに書き込み [#qf1ebcf6]
一番簡単なのは、''/etc/rc.d/rc.local''ファイルの末尾に、以下の記述を追加します。
 /usr/local/apache2/bin/apachectl startssl


*initdを使用する [#z8ebc769]
 /etc/init.d
こちらに起動スクリプトを設置して、chkconfigやserviceコマンドを使用して管理する場合の例です。

-次に紹介するスクリプトを用意して、''/etc/init.d/httpd''に設置
-以下のコマンドを実行して登録
 # /sbin/chkconfig --add httpd
 # /sbin/chkconfig httpd on

**スクリプト例 [#g3a7d6d6]
ファイル名は''http''として下さい。
(以下は、Vine Linuxにhttpdをrpmインストールした場合に設置される起動スクリプトを参考に、作成しました)

 #!/bin/bash
 #
 # Startup script for the Apache Web Server
 #
 # chkconfig: - 85 15
 # description: Apache is a World Wide Web server.  It is used to serve \
 #	       HTML files and CGI.
 
 # Source function library.
 . /etc/rc.d/init.d/functions
 
 # Path to the httpd binary.
 rootdir=/usr/local/apache2
 httpd=${rootdir}/bin/apachectl
 prog=httpd
 RETVAL=0
 
 start() {
 	echo -n $"Starting $prog: "
 	${httpd} startssl
 	RETVAL=$?
 	echo
 	return $RETVAL
 }
 stop() {
 	echo -n $"Stopping $prog: "
     ${httpd} stop
 	RETVAL=$?
 	echo
 }
 restart() {
 	echo -n $"Restarting $prog: "
     ${httpd} restart
 	RETVAL=$?
 	echo
 }
 
 # See how we were called.
 case "$1" in
   start)
 	start
 	;;
   stop)
 	stop
 	;;
   restart)
 	restart
 	;;
   configtest)
 	$httpd -t
 	RETVAL=$?
 	;;
   *)
 	echo $"Usage: $prog {start|stop|restart|reload|configtest}"
 	exit 1
 esac
 
 exit $RETVAL


RIGHT:2005-09-18 (日) 18:25:58
----
[[家サーバ管理帳]]
トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS