Apache 2.2 のインストール

httpd-2.2.9をインストールする。

インストール前の準備

Apacheのインストールには以下が必要。無ければインストールする。

  • gcc
  • libtool
  • autoconf
  • perl(バージョン5以上)

またhttpdの古いバージョンがプリインストールされている場合はアンインストールしておく。


# yum remove httpd
opensslをインストールする。

# cd /usr/local/src
# wget http://www.openssl.org/source/openssl-0.9.8e.tar.gz
# tar xzvf openssl-0.9.8.e
# cd /usr/local/src/openssl-0.9.8e
# ./config --prefix=/usr/local/openssl -fPIC shared
# make
# make install
# cd /etc/ld.so.conf.d
# vim openssl.conf
以下を記述

/usr/local/openssl/lib

# ldconfig

インストール

ソースをダウンロードする。


# cd /usr/local/src
# wget http://archive.apache.org/dist/httpd/httpd-2.2.9.tar.gz
# tar xzvf httpd-2.2.9.tar.gz

aprapr-utilをインストールする。


# cd /usr/local/src/httpd-2.2.9/srclib/apr
# ./configure --prefix=/usr/local/apr-httpd/
# make
# make install
# cd /usr/local/src/httpd-2.2.9/srclib/apr-util
# ./configure --prefix=/usr/local/apr-util-httpd/ --with-apr=/usr/local/apr-httpd/
# make
# make install

httpdをインストールする。
組み込むモジュールの詳細はhttp://www.apache.jp/manual/mod/を参考。
openssl、aprapr-utilはインストール場所を指定する。


# cd /usr/local/src/httpd-2.2.9
# ./configure --prefix=/usr/local/httpd-2.2.9 \
--enable-dav=shared \
--enable-dav-fs=shared \
--enable-dav-lock=shared \
--enable-proxy=shared \
--enable-proxy-balancer=shared \
--enable-proxy-ajp=shared \
--enable-rewrite=shared \
--enable-ssl=shared \
--with-ssl=/usr/local/openssl \
--with-apr=/usr/local/apr-httpd \
--with-apr-util=/usr/local/apr-util-httpd
# make
# make install

シンボリックリンクを作成する。


# ln -s /usr/local/httpd-2.2.9 /usr/local/httpd
※再インストールする場合は、/usr/local/httpd-2.2.9を丸ごと削除して、make distcleanを実行する。

Apache起動ユーザの作成


# groupadd httpd
# useradd -g httpd -d /var/empty/httpd -s /sbin/nologin httpd
権限を変更する。

# chown -R httpd:httpd /usr/local/httpd
# chown -R httpd:httpd /usr/local/httpd-2.2.9
httpd.confを以下のように修正する。

# User daemon
# Group daemon
User httpd
Group httpd

公開ディレクトリの作成

ディレクトリ構成は以下のようにする。

  • /var/www/

     Apache用コンテンツ置き場

  • /var/www/public/

     公開サービス用ディレクト

     社内共有webdav
権限を変更する。


# chown -R httpd:httpd /var/www
httpd.confを以下のように修正する。

# DocumentRoot "/usr/local/httpd-2.2.9/htdocs"
DocumentRoot "/var/www/public"
 
・・・
 
# This should be changed to whatever you set DocumentRoot to.
#
#





※追記
インストール後に、configureオプションに--enable-soが無いことに気付いた。
公式(http://www.apache.jp/manual/programs/configure.html)によると


enable-so
Enable DSO capability provided by mod_so. This module will be automatically enabled if you use the --enable-mods-shared option.
ということで--enable-soオプションは必須だと思ったのだが、httpd -Mコマンドで組み込まれたモジュールを調べるとso_moduleがちゃんと入っている。

# /usr/local/httpd/bin/httpd -M
>Loaded Modules:
> core_module (static)
> authn_file_module (static)
> authn_default_module (static)
> authz_host_module (static)
> authz_groupfile_module (static)
> authz_user_module (static)
> authz_default_module (static)
> auth_basic_module (static)
> include_module (static)
> filter_module (static)
> log_config_module (static)
> env_module (static)
> setenvif_module (static)
> mpm_prefork_module (static)
> http_module (static)
> mime_module (static)
> status_module (static)
> autoindex_module (static)
> asis_module (static)
> cgi_module (static)
> negotiation_module (static)
> dir_module (static)
> actions_module (static)
> userdir_module (static)
> alias_module (static)
> so_module (static)
> proxy_module (shared)
> proxy_connect_module (shared)
> proxy_ftp_module (shared)
> proxy_http_module (shared)
> proxy_ajp_module (shared)
> proxy_balancer_module (shared)
> ssl_module (shared)
> dav_module (shared)
> dav_fs_module (shared)
> rewrite_module (shared)
>Syntax OK
デフォルトで組み込んでくれるようだ。