在Apache中创建子域

时间:2015-10-12 19:19:50

标签: ubuntu dns apache2 virtualhost subdomain

所以我在apache2 / sites-available中的默认文件是

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/leaguenotes
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

我希望有一个子域名cms.leaguenotes.com,它显然会导致我的cms文件夹,这里是我的cms.leaguenotes.com.conf文件

<VirtualHost *:80>
ServerName cms.leaguenotes.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/cms.leaguenotes
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

然后我也做了sudo a2ensite cms.leaguenotes.com和服务apache2重启,不幸的是当我去cms.leaguenotes.com时没有出现(我添加了文件夹并添加了一个示例索引)

1 个答案:

答案 0 :(得分:0)

第1步:运行apachectl configtest并确保没有错误。如果有解决方法,请重复。

步骤2:确保您的域指向正确的DNS服务器。 Ping它并检查IP返回是否正确。您可能只需等待添加的子域以使其传播DNS。

步骤3:检查错误日志中的提示。