【问题标题】:Vhost configuration on apacheapache上的虚拟主机配置
【发布时间】:2011-10-14 04:46:54
【问题描述】:

我的 apache 服务器有问题。

我刚刚进行了全新安装(debian 6.0)。

我在 /etc/apache2/sites-available 中创建了两个配置文件:mysite.com 和 dev.mysite.com,我使用 a2ensite 命令启用了它们,然后我重新加载了服务器(/etc/init.d/apache2重新加载)

我修改了我的主机文件以将两个请求重定向到我的服务器。尝试访问 mysite.com 时我没有问题,但是当我尝试访问 dev.mysite.com 时,我得到了 mysite.com 的内容。

这是我的配置文件:

apache2.conf 的一部分

# Include ports listing
Include ports.conf

# Include the virtual host configurations:
Include sites-enabled/*

ports.conf 文件

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz

NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

sites-available/mysite.com 文件:

<VirtualHost *>
        ServerAdmin web@mydomain.com
        ServerName www.mysite.com
        ServerAlias mysites.com
        ServerAlias www.mysites.com
        ServerAlias mysite.com
        DocumentRoot /media/Data/www/mysiteCom
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /media/Data/www/mysiteCom>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
        ErrorLog /var/log/apache2/error_mysiteCom
        LogLevel warn
        CustomLog /var/log/apache2/access_mysiteCom combined
        ServerSignature Off
</VirtualHost>

我的站点可用/dev.mysite.com 文件:

<VirtualHost *>
        ServerAdmin web@mydomain.com
        ServerName dev.mysite.com
        ServerAlias dev.mysites.com
        DocumentRoot /media/Data/www/devMysiteCom
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /media/Data/www/devMysiteCom>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
        ErrorLog /var/log/apache2/error_devMysiteCom
        LogLevel warn
        CustomLog /var/log/apache2/access_devMysiteCom combined
        ServerSignature Off
</VirtualHost>

知道我做错了什么吗?

【问题讨论】:

  • 这实际上帮助我正确设置了我的虚拟主机。非常感谢!

标签: apache configuration subdomain virtualhost virtual-hosts


【解决方案1】:

我发现了我的错误。

实际上,要访问哪个端口似乎是强制性的,所以我不得不在VirtualHost中设置它:

<VirtualHost *:80>

【讨论】:

    猜你喜欢
    • 2015-02-01
    • 2011-05-04
    • 2017-06-14
    • 2012-08-22
    • 2011-10-13
    • 1970-01-01
    • 1970-01-01
    • 2013-07-12
    相关资源
    最近更新 更多