Apache的虚拟主机不工作的子域 [英] Apache vhost not working for subdomains

查看:180
本文介绍了Apache的虚拟主机不工作的子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个配置但两者的网址app.test.com&安培; stage.test.com
重定向到同一code /部署

 <虚拟主机*:80>
    服务器名app.test.com
    的DocumentRoot的/ var / www / html等/测试,正式版/网络
    <目录的/ var / www / html等/测试,正式版/网络>
        选择了FollowSymLinks索引
        所有的AllowOverride
    < /目录>
    错误日志日志/测试prod__error_log
    的CustomLog日志/测试prod_access_log常见
< /虚拟主机>
<虚拟主机*:80>
    服务器名stage.test.com
    的DocumentRoot的/ var / www / html等/测试/网络
   <目录的/ var / www / html等/测试/网络>
        选择了FollowSymLinks索引
        所有的AllowOverride
   < /目录>
   错误日志日志/测试website_error_log
   的CustomLog日志/测试website_access_log常见
 < /虚拟主机>


解决方案

这个通常的错误离开了了NameVirtualHost 指令,如果你还在使用的httpd 2.2

添加以下在您的配置文件,它可能会工作。

  *了NameVirtualHost 0.80

您可能需要阅读href=\"http://httpd.apache.org/docs/2.2/vhosts/name-based.html\" rel=\"nofollow\">命名为基础的虚拟主机支持

I have this configuration but both url app.test.com & stage.test.com redirect to same code/deployment

<VirtualHost *:80>
    ServerName app.test.com
    DocumentRoot /var/www/html/Test-Prod/web
    <Directory "/var/www/html/Test-Prod/web">
        Options Indexes FollowSymLinks
        AllowOverride All
    </Directory>
    ErrorLog logs/test-prod__error_log
    CustomLog logs/test-prod_access_log common
</VirtualHost>
<VirtualHost *:80>
    ServerName stage.test.com
    DocumentRoot /var/www/html/Test/web
   <Directory "/var/www/html/Test/web">
        Options Indexes FollowSymLinks
        AllowOverride All
   </Directory>
   ErrorLog logs/test-website_error_log
   CustomLog logs/test-website_access_log common
 </VirtualHost>

解决方案

The usual error for this is leaving out the NameVirtualHost directive if you're still using httpd 2.2

Add the following in your config file and it'll probably work

NameVirtualHost *.80

You might want to read the documentation for Named-based Virtual Host Support with httpd 2.2.

这篇关于Apache的虚拟主机不工作的子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆