【发布时间】: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