Amazon Lightsail WordPress インスタンスにサブドメインとして追加の HTML ウェブサイトを作成したいと考えています。
簡単な説明
Lightsail WordPress インスタンスには WordPress アプリケーションがプリインストールされています。現在の WordPress のウェブサイトに加えてサブドメインをホストするには、Apache 設定ファイルに追加の仮想ホストを作成します。
解決策
Bitnami スタックのインストールタイプに応じた手順を実行します。
インストールタイプを確認するには、次のコマンドを実行します。
`test ! -f "/opt/bitnami/common/bin/openssl" && echo "Approach A: Using system packages." || echo "Approach B: Self-contained installation."`
Bitnami スタックがネイティブ Linux システムパッケージを使用している
Bitnami スタックがネイティブ Linux システムパッケージを使用している場合は、次の手順を実行してください。
-
次のコマンドを実行して、Apache 設定ディレクトリにある新しい vhost ファイルを開きます。sub.example.com を使用するサブドメインの名前に置き換えてください。
sudo nano /opt/bitnami/apache2/conf/vhosts/sub.example.com-vhost.conf
-
設定ファイルに次のエントリを追加します。sub.example をサブドメインの名前に、/opt/bitnami/wordpress/sub をサブドメインをホストする予定のディレクトリに置き換えてください。
<VirtualHost *:80>
ServerName sub.example.com
DocumentRoot "/opt/bitnami/wordpress/sub"
<Directory "/opt/bitnami/wordpress/sub">
Options +MultiViews +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
-
サブドメインの HTTPS を有効にするには、サブドメインの SSL/TLS 証明書を購入してインストールします。次に、仮想ホストファイル /opt/bitnami/apache2/conf/vhosts/sub.example.com-vhost.conf の最後に次のエントリを追加します。ServerName、DocumentRoot、SSLCertificateFile、および SSLCertificateKeyFile を適切な値に置き換えます。
<VirtualHost *:443>
ServerName sub.example.com
DocumentRoot "/opt/bitnami/wordpress/sub"
SSLEngine on
SSLCertificateFile "/opt/bitnami/apache2/conf/bitnami/certs/server.crt"
SSLCertificateKeyFile "/opt/bitnami/apache2/conf/bitnami/certs/server.key"
<Directory "/opt/bitnami/wordpress/sub">
Options +MultiViews +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
-
ファイルを保存するには、Ctrl+x を押して Y を押し、Enter キーを押します。
-
次のコマンドを実行して Apache を再起動します。
sudo /opt/bitnami/ctlscript.sh restart apache
Bitnami スタックが自己完結型のインストールである
Bitnami スタックが自己完結型インストールの場合は、次の手順を実行してください。
-
次のコマンドを実行して、Apache 設定ディレクトリにある新しい vhost ファイルを開きます。
sudo nano /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf
-
ファイルに次のエントリを追加します。sub.example を使用するサブドメイン名に、/opt/bitnami/apps/wordpress/htdocs/sub をサブドメインをホストする予定のディレクトリに置き換えてください。
<VirtualHost *:80>
ServerName sub.example.com
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs/sub"
<Directory "/opt/bitnami/apps/wordpress/htdocs/sub">
Options +MultiViews +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
-
サブドメインの HTTPS を有効にするには、サブドメインの SSL/TLS 証明書を購入してインストールします。次に、vhost ファイル /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf の最後に次のエントリを追加します。ServerName、DocumentRoot、SSLCertificateFile、および SSLCertificateKeyFile を適切な値に置き換えます。
<VirtualHost *:443>
ServerName sub.example.com
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs/sub"
SSLEngine on
SSLCertificateFile "/opt/bitnami/apache2/conf/server.crt"
SSLCertificateKeyFile "/opt/bitnami/apache2/conf/server.key"
<Directory "/opt/bitnami/apps/wordpress/htdocs/sub">
Options +MultiViews +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
-
ファイルを保存するには、キーボードの Ctrl+x を押して Y を押し、Enter キーを押します。
-
次のコマンドを実行して Apache を再起動します。
sudo /opt/bitnami/ctlscript.sh restart apache