设置子域名 Apache 无法正常工作

设置子域名 Apache 无法正常工作

当我在 apache 配置文件中设置子域时,我检查子域运行正常,但是当我检查主域中的目录时,它告诉未找到服务器,我该如何添加子域并确保它们都正常运行?

<VirtualHost *:80>
ServerName www.domain.com
DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost *:80>
ServerName amg.domain.com
DocumentRoot /var/www/amg.domain.com/html
</VirtualHost>

答案1

尝试下面的 apache 虚拟主机并将“ip_address”替换为真实 IP

NameVirtualHost ip_address:80

<VirtualHost ip_address:80>
    ServerName www.domain.com
    DocumentRoot /var/www/html

    ErrorLog logs/error.log
    CustomLog logs/access.log combined
</VirtualHost>

<VirtualHost ip_address:80>
    ServerName amg.domain.com
    DocumentRoot /var/www/amg.domain.com/html

    ErrorLog logs/subdomain_error.log
    CustomLog logs/subdomain_access.log combined
</VirtualHost>

相关内容