Конфигурация Vhost на Apache - PullRequest
1 голос
/ 27 июля 2011

У меня проблема с моим сервером Apache.

Я только что сделал новую установку (debian 6.0).

Я создал два файла конфигурации: mysite.com и dev.mysite.com в / etc / apache2 / sites-available, я включил их командой a2ensite и перезагрузил сервер (/etc/init.d/apache2 reload)

Я изменил свой хост-файл, чтобы перенаправить двазапросы на мой сервер.У меня нет проблем при попытке связаться с 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>

мои сайты-available / 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>

Есть идеи, что я сделал не так?

1 Ответ

2 голосов
/ 27 июля 2011

Я нашел свою ошибку.

На самом деле, кажется, что обязательно указывать, к какому порту будет осуществляться доступ, поэтому мне пришлось установить его в VirtualHost:

<VirtualHost *:80>
...