LINUX.ORG.RU
решено ФорумAdmin

[apache][debian] виртуалхосты

 ,


0

1

Баянистый вопрос, но в поиске не нашёл ответа.

На VPS стоит Debian 6 и apache2. Есть некий домен example.com, для него есть конфиг:

<VirtualHost *:80>
  DocumentRoot /var/www/default
  ...
</VirtualHost>

Добавил конфиг для поддомена:

<VirtualHost test.example.com:80>
  DocumentRoot /var/www/test
  ...
</VirtualHost>

В итоге по любым запросам открываются файлы из /var/www/test. ЧЯДНТ? Нужно запросы к существующим поддоменам «отправлять» им, остальные отправлять на домен второго уровня. Помогите с конфигом.

★★

Последнее исправление: VeroLom (всего исправлений: 1)

Ответ на: комментарий от deb
#sites-enabled/000-default
<VirtualHost domain.com:80>
        ServerAdmin ver@0xff.su

        DocumentRoot /var/www/default
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/default/>
                Options FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/default.error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/default.access.log combined

</VirtualHost>
# sites-enabled/001-yii
<VirtualHost yii.domain.com:80>
        ServerAdmin ver@0xff.su

        DocumentRoot /var/www/yii
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/yii/>
                Options FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/yii.error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/yii.access.log combined

</VirtualHost>
VeroLom ★★
() автор топика
Ответ на: комментарий от anthill

и еще добавь ServerName

т.е. у тебя должно получится примерно так:

<VirtualHost yii.domain.com:80>
        ServerAdmin ver@0xff.su
        ServerName yii.domain.com # Та самая строчка
        DocumentRoot /var/www/yii
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/yii/>
                Options FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/yii.error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/yii.access.log combined

</VirtualHost>

anthill
()
Ответ на: комментарий от anthill

В ports.conf такие строчки уже были. Добавил ServerName - получаю такое:

Reloading web server config: apache2[Mon Feb 06 16:17:43 2012] [warn] VirtualHost cabz.su:80 overlaps with VirtualHost yii.cabz.su:80, the first has precedence, perhaps you need a NameVirtualHost directive
[Mon Feb 06 16:17:43 2012] [warn] NameVirtualHost *:80 has no VirtualHosts

VeroLom ★★
() автор топика

б***ь, вы бы хоть документацию читали. А потом говорите, что вам никто не отвечает и оскорбляет.

Syntax: <VirtualHost addr[:port] [addr[:port]] ...> ... </VirtualHost>

xpahos ★★★★★
()
Ответ на: комментарий от VeroLom

А если так?

<VirtualHost *:80>
        ServerAdmin ver@0xff.su
        ServerName yii.domain.com # Та самая строчка
        DocumentRoot /var/www/yii
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/yii/>
                Options FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/yii.error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/yii.access.log combined

</VirtualHost>

В помощь: http://httpd.apache.org/docs/2.0/vhosts/examples.html

anthill
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.