【问题标题】:Google Compute Engine Apache2 subdomain still directed a home instead of virtual host folderGoogle Compute Engine Apache2 子域仍然指向主页而不是虚拟主机文件夹
【发布时间】:2019-02-05 23:02:47
【问题描述】:

我一直在尝试在我的 Google Cloud Console 中创建子域,然后将它们定向到我的 /var/www 目录中的文件夹。

我创建了一个子域:

DNS Name: subdomain.example.com
Type: CNAME
TTL: 300
Data: example.com

我创建了一个文件夹

/var/www/子域

我创建了一个带有消息“子域!”的文件

/var/www/subdomain/index.html

之后,我复制了我的 000-default.conf

cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/subdomain.conf

我将新文件代码编辑为:

<VirtualHost *:80>
        ServerAdmin webmaster@subdomain.example.com
        DocumentRoot /var/www/subdomain
        ServerName subdomain.example.com
        ServerAlias www.subdomain.example.com
        Redirect permanent / https://subdomain.example.com/
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

然后我做了

sudo a2ensite subdomain.conf
sudo service apache2 restart

然而我的子域仍然指向文档根/var/www/html

我注意到当我执行systemctl reload apache2 时出现错误Failed to connect to bus: No such file or directory

我错过了一个步骤还是需要添加其他内容?

【问题讨论】:

    标签: apache2 subdomain virtualhost


    【解决方案1】:

    问题是配置了http但没有配置https。

    必须添加到 default-ssl.conf

    <VirtualHost *:443>
     ServerName www.yoursite.com
     DocumentRoot /var/www/site
     SSLEngine on
     SSLCertificateFile /path/to/www_yoursite_com.crt
     SSLCertificateKeyFile /path/to/www_yoursite_com.key
     SSLCertificateChainFile /path/to/DigiCertCA.crt
    </VirtualHost>
    

    【讨论】:

      猜你喜欢
      • 2013-06-11
      • 2014-08-21
      • 1970-01-01
      • 2011-12-24
      • 2016-10-26
      • 2018-07-25
      • 2011-08-23
      • 1970-01-01
      • 2014-01-19
      相关资源
      最近更新 更多