如何在 Bitnami LAMP 堆栈中为子域配置虚拟主机?

How to configure virtualhost for sub domain in Bitnami LAMP Stack?

我已经成功地使用 Bitnami LAMP 在 Google 控制台上部署了我的应用程序。我正在尝试设置子域,但我不断收到此错误。

无法访问此站点 subdomain.domain.com 找不到服务器 IP 地址。

这是我在 httpd-vhosts.conf

中的条目
    <VirtualHost *:80>
    ServerAdmin webmaster@DOMAIN.com
    DocumentRoot "/opt/bitnami/apache2/htdocs/DOMAIN_FILES"
    ServerName DOMAIN.com
    ServerAlias www.DOMAIN.com
    ErrorLog "logs/DOMAIN.com.com-error_log"
    CustomLog "logs/DOMAIN.com-access_log" common
</VirtualHost>

<VirtualHost *:443>
    ServerAdmin webmaster@DOMAIN.com
    DocumentRoot "/opt/bitnami/apache2/htdocs/DOMAIN_FILES"
    ServerName DOMAIN.com
    ServerAlias www.DOMAIN.com
    ErrorLog "logs/DOMAIN.com.com-error_log"
    CustomLog "logs/DOMAIN.com-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@DOMAIN.com
    DocumentRoot "/opt/bitnami/apache2/htdocs/SUBDOMAIN_FILES"
    ServerName subdomain.DOMAIN.com
    ServerAlias www.subdomain.DOMAIN.com
    ErrorLog "logs/subdomain.DOMAIN.com.com-error_log"
    CustomLog "logs/subdomain.DOMAIN.com-access_log" common
</VirtualHost>

<VirtualHost *:443>
    ServerAdmin webmaster@DOMAIN.com
    DocumentRoot "/opt/bitnami/apache2/htdocs/SUBDOMAIN_FILES"
    ServerName subdomain.DOMAIN.com
    ServerAlias www.subdomain.DOMAIN.com
    ErrorLog "logs/subdomain.DOMAIN.com.com-error_log"
    CustomLog "logs/subdomain.DOMAIN.com-access_log" common
</VirtualHost>

bitnami.conf 代码是

    # Default Virtual Host configuration.

<IfVersion < 2.3 >
  NameVirtualHost *:80
  NameVirtualHost *:443
</IfVersion>

<VirtualHost _default_:80>
  DocumentRoot "/opt/bitnami/apache2/htdocs"
  <Directory "/opt/bitnami/apache2/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride All
    <IfVersion < 2.3 >
      Order allow,deny                          
      Allow from all
    </IfVersion>
    <IfVersion >= 2.3 >
      Require all granted
    </IfVersion>
  </Directory>

  # Error Documents
  ErrorDocument 503 /503.html

  # Bitnami applications installed with a prefix URL (default)
  Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
</VirtualHost>

# Default SSL Virtual Host configuration.

<IfModule !ssl_module>
  LoadModule ssl_module modules/mod_ssl.so
</IfModule>

Listen 443
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCipherSuite "EECDH+........"
SSLPassPhraseDialog  builtin
SSLSessionCache "shmcb:/opt/bitnami/apache2/logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300

<VirtualHost _default_:443>
  DocumentRoot "/opt/bitnami/apache2/htdocs"
  SSLEngine on
SSLCertificateFile "/opt/bitnami/apache2/conf/server.crt"
SSLCertificateKeyFile "/opt/bitnami/apache2/conf/server.key"

  <Directory "/opt/bitnami/apache2/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride All
    <IfVersion < 2.3 >
      Order allow,deny                          
      Allow from all
    </IfVersion>
    <IfVersion >= 2.3 >
      Require all granted
    </IfVersion>
  </Directory>

  # Error Documents
  ErrorDocument 503 /503.html

  # Bitnami applications installed with a prefix URL (default)
  Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
</VirtualHost>


# Bitnami applications that uses virtual host configuration
Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf"

bitnami-apps-vhosts.conf代码是

# Bitnami applications installed in a Virtual Host
Include "/opt/bitnami/apache2/conf/extra/httpd-vhosts.conf"

domain.com 工作正常。有人可以帮我修复 subdomain.domain.com

您是否为您的子域地址添加了 DNS 条目?

如果您想将流量从您的主域地址和子域地址定向到一个 IP 地址,这将是必要的。

您收到的错误消息可能是子域地址未与 IP 地址相关联的结果。

如果您还没有为子域地址添加 DNS 条目,这里有一些关于将子域添加到您的 DNS 配置的有用信息here and here