VIne Linux 3.1にApache 2.0.54をインストールする方法

Vine Evo

Apache 2.0.54をインストールする (VineLinux)

ProEvo / Vine Evo / Apache 2.0.54をインストールする (VineLinux)

Vine Linux 3.1にApache 2.0.54をインストールする方法


1. Apache2について

1.1 Apache2とは何か?

Apache2はApacheのバージョン2系列の略称で、Apacheの後継Webサーバです。
Apache2はApache 1.xと比べて以下の点が改良されています。

などです。
Apache2.0の新機能については、「Apache 2.0 の新機能の概要」を参照してください。

1.2 Apache2を手に入れる

Apache2はApache 日本語公式サイトからダウンロードできます。 2005年7月16日現在の最新安定版は2.0.54です。次の手順で、これをダウンロードします。

  1. Apache日本語公式サイトApacheのダウンロードのページにアクセスします。 [Apacheのダウンロード]
  2. ダウンロードサーバのリンクから適当なサイトを選びアクセスします。
    [ファイル一覧]
  3. ファイル一覧から、httpd-2.0.54.tar.bzへのリンクをクリックし、ファイルを適当なディレクトリにダウンロードします。
    [ダウンロード実行]

このようにしてファイルのダウンロードが成功すれば、Apache2を手に入れたことになります。

2. Apache2のインストール

2.1 Apache2をインストールする

ダウンロードしたtarballを展開し、コンパイルすることでApache2をVineLinuxにインストールします。
次の手順で、Apache2をインストールします。
sslを使うには"openssl-devel"パッケージを導入する必要があります。

  1. tarballを/usr/local/src/下にコピーします。 [atsushifx@agartha Archives]$ cp httpd-2.0.54.tar.bz2 /usr/local/src
  2. /usr/local/srcに移動します。 [atsushifx@agartha Archives]$ cd /usr/local/src
  3. アーカイブファイルからファイルを展開します。 [atsushifx@agartha src]$ tar zxvf httpd-2.0.54.tar.bz2
  4. Apache2ソースディレクトリに移動します。 [atsushifx@agartha src]$ cd httpd-2.0.54
  5. ./cfとしconfigureを実行します。 [atsushifx@agartha httpd-2.0.54]$ chmod +x cf; ./cf
    ./cf
    ./configure \
     --prefix=/usr/local/apache --mandir=/usr/local/man \
     --enable-charset-lite --enable-cache \
     --enable-file-cache --enable-disk-cache --enable-mem-cache \
     --enable-so \
     --enable-auth=shared --enable-include=shared --enable-env=shared \
     --enable-mime-magic=shared --enable-headers=shared \
     --enable-unique-id=shared --enable-setenvif=shared \
     --enable-mime=shared --enable-autoindex=shared \
     --enable-status=shared --enable-info=shared \
     --enable-suexec=shared --enable-cgid=shared --enable-cgi=shared \
     --enable-vhost-alias=shared --enable-negotiation=shared \
     --enable-dir=shared --enable-userdir=shared --enable-alias=shared \
     --enable-rewrite=shared --enable-ssl=shared
    
  6. makeして実行ファイルを作成します。
    [atsushifx@agartha httpd-2.0.54]$ make
  7. 実行ファイルをインストールします。
    
    [atsushifx@agartha httpd-2.0.54]$ su
    Password: ******
    [atsushifx@agartha httpd-2.0.54]$ make install
    

以上でApache2のインストールは終了です。

2.2 Apache2の設定をする

2,1の操作だけでもApache2の軌道はできます。
しかし、色々と具合が悪いので使いやすいようにApache2の設定をします。
以下のようにhttpd.confファイルを設定します。

/usr/local/apache/conf/httpd.conf
 262|ExtendedStatus On

 290|User nobody
 291|Group nobody

 300|ServerAdmin webmaster@agartha

 316|ServerName agartha

 398|<Directory /home/*/public_html>
 399|    AllowOverride All
 400|    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
 401|#    <Limit GET POST OPTIONS PROPFIND>
 402|#        Order allow,deny
 403|#        Allow from all
 404|#    </Limit>
 405|#    <LimitExcept GET POST OPTIONS PROPFIND>
 406|#        Order deny,allow
 407|#        Deny from all
 408|#    </LimitExcept>
 409|</Directory>

 419|DirectoryIndex index.html index.html.var index.htm index.php

 471|HostnameLookups On

 560|ServerSignature On

 731|DefaultLanguage ja

 872|AddHandler cgi-script .cgi

 999|<Location /server-status>
1000|    SetHandler server-status
1001|    Order deny,allow
1002|    Deny from all
1003|    Allow from localhost agartha tir-n-org
1004|</Location>

1011|<Location /server-info>
1012|    SetHandler server-info
1013|    Order deny,allow
1014|    Deny from all
1015|    Allow from localhost agartha tir-n-org
1006|</Location>

これで、正常にApache2が起動できるようになります。
[root@agartha tmp]$ /usr/local/apache/bin/apachectl start
として、何のメッセージも出なければ正常です。

2.3 動作確認

Apache2が正常に動作しているか、動作の確認をします。
http://agarhaにアクセスし、次の画面が出ればApache2は正常に動作しています。
[Apache起動画面]

2.4 起動スクリプトの設定

最後に、VineLinuxの電源をOnにしたときにApache2が自動的に動作するように起動スクリプトを設定します。
次の手順で、起動スクリプトを設定します。

  1. /etc/init.d/下にhttpdを言うファイル名で起動スクリプトを作成します。
    ファイルの内容は次のようになります。
    /etc/init.d/httpd
    #!/bin/sh
    # $Id: apache-2.0.54.html 2 2007-02-28 14:35:40Z atsushifx $
    # Apache2 Web Server server auto starter
    # Author: Atsushi Furukawa <atsushifx@aglabo.com>
    
    # For Redhat-ish systems
    #
    # chkconfig: - 84 15
    # processname: /usr/local/apache/binttpd
    # config: /usr/local/apache/conf/httpd.conf
    # description:  PostgreSQL Database starter
    export LANG=ja_JP.eucJP
    
    . /etc/init.d/functions
    
    # See how we were called.
    apachedir=/usr/local/apache
    apachectl=$apachedir/bin/apachectl
    apache="httpd"
    start()
    {
      pid=`/sbin/pidof -s httpd`
      if [ $pid ]; then
        echo $"$apache is already running."
      else
        $apachectl start
        echo_success
      fi
      echo
    }
    
    stop()
    {
      pid=`/sbin/pidof -s httpd`
      if [ $pid ]; then
        $apachectl stop
        echo_success
      else
        echo $"$apache is already stopped."
      fi
      echo
    }
    
    case $1 in
      start)
        start
        ;;
      stop)
        stop
        ;;
      restart)
        stop
        sleep 1
        start
        ;;
      status)
        $apachectl status
        RETVAL=$?
        ;;
      *)
        echo "Usage: $0 {start|stop|status|restart}"
        exit 1
    esac
    
    exit 0
    
  2. 作成したhttpdに実行フラグを立て、このスクリプトでApache2が起動するか確認します。
  3. chkconfigで起動スクリプトを設定します。 [root@agartha init.d]$ /sbin/chkconfig httpd on

以上で起動スクリプトの設定は終了です。
以後、サーバーの電源をOnにした時にApache2が起動するようになります。



$Revision: 2 $
$Date: 2007-02-28 23:35:40 +0900 (豌エ, 28 2譛 2007) $