とにあえず、ドメインaaa.bizとbbb.infoの2ドメインでapache22を動かすことにします。

他モジュールがらみの細かいところは後にして、とりあえずブラウザからアクセスできるまでのところで。

修正するのは、/usr/local/etc/apache22の中のhttpd.confextra以下の必要なファイルです。

httpd.conf

上の方の記述は放っておきましょう。

とりあえずは、以下の部分を修正。

# Supplemental configuration
#
# The configuration files in the etc/apache22/extra/ directory can be
# included to add extra features or to modify the default configuration of
# the server, or you may simply copy their contents here and change as
# necessary.

# Server-pool management (MPM specific)
#Include etc/apache22/extra/httpd-mpm.conf

# Multi-language error messages
#Include etc/apache22/extra/httpd-multilang-errordoc.conf

# Fancy directory listings
#Include etc/apache22/extra/httpd-autoindex.conf

# Language settings
#Include etc/apache22/extra/httpd-languages.conf

# User home directories
#Include etc/apache22/extra/httpd-userdir.conf----コメントを外す

# Real-time info on requests and configuration
#Include etc/apache22/extra/httpd-info.conf

# Virtual hosts
#Include etc/apache22/extra/httpd-vhosts.conf----コメントを外す(2ドメイン使うから)

# Local access to the Apache HTTP Server Manual
#Include etc/apache22/extra/httpd-manual.conf

# Distributed authoring and versioning (WebDAV)
#Include etc/apache22/extra/httpd-dav.conf

# Various default settings
#Include etc/apache22/extra/httpd-default.conf----コメントを外す

# Secure (SSL/TLS) connections
#Include etc/apache22/extra/httpd-ssl.conf
#
# Note: The following must must be present to support
# starting without SSL on platforms with no /dev/random equivalent
# but a statically compiled-in mod_ssl.
#
SSLのところは後でSSLをキーを移すときに外すので今はこのまま。


extra/httpd-vhosts.conf

バーチャルホストを定義します。今回2ドメインなのでここで設定します。

<VirtualHost *:80>
ServerAdmin ドメイン1のweb管理者メアド
DocumentRoot "ドメイン1のドキュメントルート"
ServerName ドメイン1のサーバー名(www.domain1.comとか)
ErrorLog "/var/log/ドメイン1のエラーログファイル名"
CustomLog "/var/log/ドメイン1のアクセスログファイル名" common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin ドメイン2のweb管理者メアド
DocumentRoot "ドメイン2のドキュメントルート"
ServerName ドメイン2のサーバー名(www.domain2.comとか)
ErrorLog "/var/log/ドメイン2のエラーログファイル名"
CustomLog "/var/log/ドメイン2のアクセスログファイル名" common
</VirtualHost>

要するにServerNameとDocumentRootで1サーバーでマルチドメインのwebを実現するわけですね。


extra/httpd-userdir.conf

ドキュメントを格納するフォルダ(ドキュメントルート)とその使い方を定義します。

<Directory "ドメイン1のドキュメントルート(/home/domain1とか)">
Order allow,deny
AllowOverride all
Allow from all
DirectoryIndex -FollowSymlinks index.html index.php index.cgi
</Directory>

こんな感じで必要ドメイン分書けばいいですね。


extra/httpd-default.conf

基本的に修正する必要ありません。