GoogleCloudPlatform(GCP)のCloud Launcher を利用した「Bitnami」でApacheをインストールした際のバーチャルホストの設定方法を紹介。
1.bitnamiの元ファイルを編集
/opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf に以下を追加
Include "/opt/bitnami/apps/xxxx/conf/httpd-vhosts.conf"
※以降は/home/apps 環境の個別アプリケーション設定にて行う。
2.apps内のhttpd-vhosts.conf設定
/home/hoge/apps/xxxx/conf/httpd-vhosts.conf に以下を追加
※hogeは、GCPユーザー ※xxxxは、bitnamiで作成するアプリケーション用ディレクトリ
<VirtualHost *:80> ServerName www2.hogehoge.com DocumentRoot "/opt/bitnami/apps/xxxx/htdocs" ErrorLog /opt/bitnami/apache2/logs/www2.hogehoge.com-error_log CustomLog /opt/bitnami/apache2/logs/www2.hogehoge.com-access_log common Include "/opt/bitnami/apps/xxxx/conf/httpd-app.conf" </VirtualHost>
※ログの出力場所は任意で設定
3.apps内のhttpd-prefix.conf設定
/home/hoge/apps/xxxx/conf/httpd-prefix.conf に以下を追加
Alias /xxxx/ "/opt/bitnami/apps/xxxx/htdocs/" Alias /xxxx "/opt/bitnami/apps/xxxx/htdocs" Include "/opt/bitnami/apps/xxxx/conf/httpd-app.conf"
4.apps内のhttpd-app.conf設定
/home/hoge/apps/xxxx/conf/httpd-app.conf に以下を追加
<Directory "/opt/bitnami/apps/xxxx/htdocs"> Options +MultiViews AllowOverride None <IfVersion < 2.3 > Order allow,deny Allow from all </IfVersion> <IfVersion >= 2.3> Require all granted </IfVersion> </Directory> Include /opt/bitnami/apps/xxxx/conf/htaccess.conf
5.apps内のhtaccess.conf設定
.htaccessの設定が必要であれば以下に追記 /home/hoge/apps/xxxx/conf/htaccess.conf に追加