0

我一直在尝试在我的 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

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

4

1 回答 1

0

问题是配置了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>
于 2018-08-31T00:52:36.130 回答