<< イントロダクション >>
J2SE(TM) セットアップ Tomcat セットアップ


4. Apache セットアップ

4.1 Apache2.0のインストール

ダウンロードでApache2.0モジュールを解凍すると、Apache作業ディレクトリが作成されていますので、作業ディレクトリに移動して、以下のコマンドを投入し、Apacheをセットアップします。

# cd httpd-2.0.49

# ./configure --prefix=/usr/local/apache2 --enable-so
# make
# make install
    ここで、configureコマンドのオプションについて簡単に説明します。
  • --prefix : Apacheをインストールするディレクトリ
  • --enable-so : DSO(Dynamic Shared Object)サポート付加

4.2 Apache定義ファイル設定

Apacheのhttpd.confファイルを、以下の内容に編集します。

# vi /usr/local/apache2/conf/httpd.conf

267行目付近
Group #-1
	↓
Group nobody

290行目付近
#ServerName new.host.name:80
	↓
ServerName localhost:80 ・・・ WWWサーバ名を指定します

4.3 Apacheの自動起動

次に、Apacheの自動起動の設定を行います。
/etc/rc.d/init.dディレクトリに移動し、vi等エディタで下記スクリプトの内容で、httpdファイルを新規作成します。(既に存在すれば下記内容で置き換え)

# cd /etc/rc.d/init.d
# vi httpd

以下のスクリプトを記述します。

#!/bin/sh
#
# Startup script for the Apache 2.0 Web Server
#
# chkconfig: 345 85 15
# description: Starts and Stops the Apache 2.0 Web server. 
# processname: httpd
# pidfile: /var/run/httpd.pid
# config: /usr/local/apache2/conf/httpd.conf

# Source function library.
. /etc/rc.d/init.d/functions

# See how we were called.
case "$1" in
  start)
	if [ -f /usr/local/apache2/bin/apachectl ]; then
		echo -n "Starting httpd: "
		daemon "/usr/local/apache2/bin/apachectl start"
		echo
		touch /var/lock/subsys/httpd
	fi
	;;
  stop)
	if [ -f /usr/local/apache2/bin/apachectl ]; then
		echo -n "Shutting down httpd: "
		daemon "/usr/local/apache2/bin/apachectl stop"
		echo
		rm -f /var/lock/subsys/httpd
		rm -f /var/run/httpd.pid
	fi
	;;
  status)
	status httpd
	;;
  restart)
	if [ -f /usr/local/apache2/bin/apachectl ]; then
		echo -n "Restarting httpd: "
		daemon "/usr/local/apache2/bin/apachectl restart"
		echo
	fi
	;;
  *)
	echo "Usage: $0 {start|stop|restart|status}"
	exit 1
esac

exit 0

作成したhttpdファイルに実行権限を付加し、ランレベルを設定します。これによりマシン起動後、自動的にApacheが起動されます。

# chmod 755 httpd

# /sbin/chkconfig --add httpd

以下のコマンドをタイプし、ランレベルが設定されたことを確認します。

# /sbin/chkconfig --list httpd
httpd   0:off	1:off	2:off	3:on	4:on	5:on	6:off


<< イントロダクション >>
J2SE(TM) セットアップ Tomcat セットアップ

更新履歴
Apache 2.0.48
Apache 2.0.46
Apache 2.0.43
Apache 2.0.40
Apache 2.0.39
Apache 2.0.36