Lightsail WordPress インスタンスのサブドメインとして HTML ウェブサイトをホストする方法を教えてください。

所要時間2分
0

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 システムパッケージを使用している場合は、次の手順を実行してください。

  1. 次のコマンドを実行して、Apache 設定ディレクトリにある新しい vhost ファイルを開きます。sub.example.com を使用するサブドメインの名前に置き換えてください。

    sudo nano /opt/bitnami/apache2/conf/vhosts/sub.example.com-vhost.conf
  2. 設定ファイルに次のエントリを追加します。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>
  3. サブドメインの HTTPS を有効にするには、サブドメインの SSL/TLS 証明書を購入してインストールします。次に、仮想ホストファイル /opt/bitnami/apache2/conf/vhosts/sub.example.com-vhost.conf の最後に次のエントリを追加します。ServerNameDocumentRootSSLCertificateFile、および 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>
  4. ファイルを保存するには、Ctrl+x を押して Y を押し、Enter キーを押します。

  5. 次のコマンドを実行して Apache を再起動します。

    sudo /opt/bitnami/ctlscript.sh restart apache

Bitnami スタックが自己完結型のインストールである

Bitnami スタックが自己完結型インストールの場合は、次の手順を実行してください。

  1. 次のコマンドを実行して、Apache 設定ディレクトリにある新しい vhost ファイルを開きます。

    sudo nano /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf
  2. ファイルに次のエントリを追加します。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>
  3. サブドメインの HTTPS を有効にするには、サブドメインの SSL/TLS 証明書を購入してインストールします。次に、vhost ファイル /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf の最後に次のエントリを追加します。ServerNameDocumentRootSSLCertificateFile、および 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>
  4. ファイルを保存するには、キーボードの Ctrl+x を押して Y を押し、Enter キーを押します。

  5. 次のコマンドを実行して Apache を再起動します。

    sudo /opt/bitnami/ctlscript.sh restart apache
AWS公式
AWS公式更新しました 1年前
コメントはありません

関連するコンテンツ