本ページは広告が含まれています。気になる広告をクリック頂けますと、サーバ運営費になります(^^
apacheで名前ベースのバーチャルホスト
apacheで名前ベースのバーチャルホスト作成方法です。
1つのサーバで、アクセスされたホスト名でホームページ表示を出しわけます。
Redirecting...
としてホームページを表示する場合と
Redirecting...
としてホームページを表示する場合に、同じホストでありながら、それぞれ違うホームページを表示する方法です。
名前ベースのバーチャルホスト
名前ベースのバーチャルホスト - Apache HTTP サーバ バージョン 2.4
手順1 http://test1.hanako.jpを有効にする
/etc/apache2/sites-available# cat test1.conf
※WordPressを利用する事を想定
<VirtualHost *:80>
ServerName test1.hanako.jp
ServerAdmin webmaster@localhost
DocumentRoot /var/www/test1
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/test1>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
上記コンフィグを有効にします。
a2ensite wordpress1.conf
手順2 http://test2.hanako.jpを有効にする
/etc/apache2/sites-available# cat test2.conf
※WordPressを利用する事を想定
<VirtualHost *:80>
ServerName test2.hanako.jp
ServerAdmin webmaster@localhost
DocumentRoot /var/www/test2
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/test2>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
上記コンフィグを有効にします
a2ensite test2.conf

