/etc/httpd/conf.d/vhost.conf中的错误vhost配置

时间:2015-01-27 10:17:54

标签: linux apache vhosts

我在/etc/httpd/conf.d/vhost.conf的虚拟主机配置如下所示:

NameVirtualHost *

<VirtualHost *>
        ServerName www.example.com
        DocumentRoot /var/www/html/site
</VirtualHost>

<VirtualHost *> 
    ServerName en.example.com 
    DocumentRoot /var/www/html/english
</VirtualHost>

<VirtualHost *> 
        ServerName photo.example.com
        DocumentRoot /var/www/html/photo
</VirtualHost>

<VirtualHost *> 
        ServerName music.example.com
        DocumentRoot /var/www/html/music
</VirtualHost>

<VirtualHost *> 
        ServerName video.example.com
        DocumentRoot /var/www/html/video
</VirtualHost>

现在,只有www.example.com/var/www/html/site显示正确的网站。所有其他子域名都提供500 internal server error。我做错了什么?


更新: 我真的很抱歉...我的域名家伙向我确认我的域名被正确路由到我的IP地址....只有在我做了dig en.example.com之后(我之前应该做的很多)我是否意识到我的域名员工做了一个愚蠢的错误配置...网址甚至没有达到我的IP地址开始...真的很抱歉麻烦的人:( :( - 这个vhost.conf文件是好的

1 个答案:

答案 0 :(得分:1)

# Ensure that Apache listens on port 80
Listen 80

# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80

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

<VirtualHost *:80> 
    ServerName en.example.com 
    DocumentRoot /var/www/html/english
</VirtualHost>

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

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

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