Vine LinuxにApache 2.0.59をインストールして、Webサーバとして利用する方法

Vine 4 hacks

/

Apache 2.0.59のインストール

音声ブラウザ専用:
本文

ProEvo / Vine Evo / Vine4 hacks / Apache 2.0.59のインストール

Vine Linux 4にWebサーバApache 2.0.59をインストールする方法


1. Apacheについて

1.1 Apacheとはなにか?

ApacheはApacheソフトウェアライセンスで公開されているWebサーバソフトウェアです。
オープンソースであることとLinuxで動くことから、Web標準のhttpサーバとなっています。

1.2 Apacheを手に入れる

ApacheはApache日本語公式サイトからダウンロードできます。
次の手順で、Apacheをダウンロードします。

  1. Apacheダウンロードサイトにアクセスします。
    [Apacheダウンロードサイト]
  2. httpd-2.0.59.tar.bz2のリンクをクリックし、Apache 2.0.59をダウンロードします。
    [ダウンロード]

以上で、Apache 2.0.59のダウンロードは終了です。

2. Apacheのインストール

2.1 Apache 2.0.59をインストールする

Apache 2.0.59のインストールは、手動コンパイルによって行います。
次の手順で、Apache 2.0.59をインストールします。

  1. httpd-2.0.59.tar.bz2を/usr/local/src/下にコピーします。
    [atsushifx@agartha Archives] cp httpd-2.0.59.tar.bz2 /usr/local/src/
  2. tarballを展開します。
    
    [atsushifx@agartha Archives]$ cd /usr/local/src
    [atsushifx@agartha src]$ tar jxvf httpd-2.0.59.tar.bz2 
    httpd-2.0.59/
    httpd-2.0.59/configure.in
    httpd-2.0.59/support/
    httpd-2.0.59/support/htpasswd.c
    httpd-2.0.59/support/utilitiesnw.def
    httpd-2.0.59/support/phf_abuse_log.cgi.in
    httpd-2.0.59/support/config.m4
    httpd-2.0.59/support/htcacheclean.dsp
     .
     .
     .
    httpd-2.0.59/config.layout
    httpd-2.0.59/INSTALL
    [atsushifx@agartha src]$ cd httpd-2.0.59
    [atsushifx@agartha src]$ 
  3. ./cfにconfigureのオプションを設定後、./cfとして./configureを実行します。
  4. ./cfとしconfigureを実行します。
    ./cf
      1:./configure \
      2: --mandir=/usr/local/man \
      3: --enable-charset-lite --enable-cache \
      4: --enable-file-cache --enable-disk-cache --enable-mem-cache \
      5: --enable-so \
      6: --enable-auth=shared --enable-include=shared --enable-env=shared \
      7: --enable-mime-magic=shared --enable-headers=shared \
      8: --enable-unique-id=shared --enable-setenvif=shared \
      9: --enable-mime=shared --enable-autoindex=shared \
     10: --enable-status=shared --enable-info=shared \
     11: --enable-suexec=shared --enable-cgid=shared --enable-cgi=shared \
     12: --enable-vhost-alias=shared --enable-negotiation=shared \
     13: --enable-dir=shared --enable-userdir=shared --enable-alias=shared \
     14: --enable-rewrite=shared --enable-ssl=shared
    実行
    
    [atsushifx@agartha httpd-2.0.59]$ chmod +x cf; ./cf
    checking for chosen layout... Apache
    checking for working mkdir -p... yes
    checking build system type... i686-pc-linux-gnu
    checking host system type... i686-pc-linux-gnu
    checking target system type... i686-pc-linux-gnu
    
    Configuring Apache Portable Runtime library ...
    
     .
     .
     .
    
    config.status: creating build/rules.mk
    config.status: creating build/pkg/pkginfo
    config.status: creating include/ap_config_auto.h
    config.status: executing default commands
    [atsushifx@agartha httpd-2.0.59]$
  5. makeを実行し、httpdを作成します。
    [atsushifx@agartha httpd-2.0.59]$ make
    Making all in srclib
    make[1]: ディレクトリ `/usr/local/src/httpd-2.0.59/srclib' に入ります
    Making all in apr
    make[2]: ディレクトリ `/usr/local/src/httpd-2.0.59/srclib/apr' に入ります
    Making all in strings
    make[3]: ディレクトリ `/usr/local/src/httpd-2.0.59/srclib/apr/strings' に入ります
    make[4]: ディレクトリ `/usr/local/src/httpd-2.0.59/srclib/apr/strings' に入ります
    /bin/sh /usr/local/src/httpd-2.0.59/srclib/apr/libtool --silent --mode=compile gcc -g -O2 -pthread -DHAVE_CONFIG_H -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -I../include -I../include/arch/unix -c apr_cpystrn.c && touch apr_cpystrn.lo
    .
    .
    .
    srclib/apr-util/xml/expat/lib -I. -I/usr/local/src/httpd-2.0.59/os/unix -I/usr/local/src/httpd-2.0.59/server/mpm/prefork -I/usr/local/src/httpd-2.0.59/modules/http -I/usr/local/src/httpd-2.0.59/modules/filters -I/usr/local/src/httpd-2.0.59/modules/proxy -I/usr/local/src/httpd-2.0.59/include -I/usr/local/src/httpd-2.0.59/modules/generators -I/usr/include/openssl -I/usr/local/src/httpd-2.0.59/modules/dav/main -export-dynamic -L/usr/local/src/httpd-2.0.59/srclib/apr-util/xml/expat/lib -o suexec suexec.lo
    make[2]: ディレクトリ `/usr/local/src/httpd-2.0.59/support' から出ます
    make[1]: ディレクトリ `/usr/local/src/httpd-2.0.59' から出ます
    [atsushifx@agartha httpd-2.0.59]$
  6. rootになりapacheをインストールします。
    
    [atsushifx@agartha httpd-2.0.59]$ su
    パスワード(P): ******
    [root@agartha httpd-2.0.59]$ make install
    Making install in srclib
    make[1]: ディレクトリ `/usr/local/src/httpd-2.0.59/srclib' に入ります
    Making install in apr
    make[2]: ディレクトリ `/usr/local/src/httpd-2.0.59/srclib/apr' に入ります
     .
     .
     .
    Installing man pages and online manual
    mkdir /usr/local/man/man8
    mkdir /usr/local/apache2/manual
    Installing build system files
    make[1]: ディレクトリ `/usr/local/src/httpd-2.0.59' から出ます
    [root@agartha httpd-2.0.59]# 

以上で、Apache 2.0.59のインストールは終了です。

2.2 Apache 2.0.59の設定

次のように、httpd.confを書き換えます。

/usr/local/apache2/conf/httpd.conf
 262:ExtendedStatus On
 .
 .
 290:User nobody
 291:Group nobody
 .
 .
 300:ServerAdmin webmaster@agartha
 .
 .
 315:ServerName agartha
 .
 .
 397:<Directory /home/*/public_html>
 398:    AllowOverride FileInfo AuthConfig Limit Indexes
 399:    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
 400:    Order allow,deny
 401:    Allow from all
 402:</Directory>
 .
 .
 411:#
 412:DirectoryIndex index.html index.html.var index.php index.cgi
 .
 .
 464:HostnameLookups On
 .
 .
 724:DefaultLanguage ja
 .
 .
 865:AddHandler cgi-script .cgi
 .
 .
 995:<Location /server-status>
 996:    SetHandler server-status
 997:    Order deny,allow
 998:    Deny from all
 999:    Allow from localhost agartha tir-n-org ys
1000:</Location>
 .
 .
1007:<Location /server-info>
1008:    SetHandler server-info
1009:    Order deny,allow
1010:    Deny from all
1011:    Allow from localhost agartha tir-n-org ys
1012:</Location>

以上で、httpd.confの設定は終了です。

2.3 起動スクリプトの作成/起動

Linux用にApache用の起動スクリプトを作成します。

/etc/init.d/httpd
#!/bin/bash
#
# Startup script for the Apache Web Server
#
# chkconfig: 345 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

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

# Source additional OPTIONS if we have them.

# Path to the httpd binary.
httpd=/usr/local/apache2/bin/apachectl
LOCKD=/var/lock/subsys
RETVAL=0

# Change the major functions into functions.
start() {
	echo -n $"Starting httpd:"
	$httpd start
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && touch $LOCKD/httpd
	return $RETVAL
}
stop() {
	echo -n $"Shutting down httpd:"
	$httpd stop
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && rm -f $LOCKD/httpd
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	$httpd status
	;;
  restart)
	stop
	start
	;;
  condrestart)
	if [ -f /var/run/httpd.pid ] ; then
		stop
		start
	fi
	;;
  configtest)
	$httpd configtest
	RETVAL=$?
	;;
  *)
	echo $"Usage: $prog {start|stop|restart|configtest|status}"
	exit 1
esac

exit $RETVAL

次のようにして、スタート時に起動するように設定します。

  1. suでrootになります。
    
    [atsushifx@agartha atsushifx]$ su
    パスワード(P): ******
    [root@agartha atsushifx]# 
  2. chkconfigを使って、起動スクリプトを設定します。
    
    [root@agartha atsushifx]# /sbin/chkconfig httpd on
    [root@agartha atsushifx]# 

以上で、起動スクリプトの設定は終了です。

3. Apacheの実行チェック

3.1 Apacheを起動する

次のようにしてApacheを起動します。

    suでrootになります。
    
    [atsushifx@agartha atsushifx]$ su
    パスワード(P): ******
    [root@agartha atsushifx]# 
  1. 起動スクリプトを使って、Apacheを起動します。
    
    [root@agartha atsushifx]# /etc/init.d/httpd start
    Starting httpd:
    [root@agartha init.d]# 

以上で、Apacheの起動は完了です。

3.2 Apacheの動作を確認する

http://agartha/server-statusにアクセスして、Apacheが動作しているかを確認します。
次の画面が表示されれば、Apacheは正常に動作しています。
[Apache server-status]

AMAZON



$Revision: 221 $
$Date: 2007-09-09 13:37:09 +0900 (日, 09 9月 2007) $