Проблема с настройкой виртуальных хостов
-
05-09-2019 - |
Вопрос
Некоторые подробности
- ХАМПП 1.7.1
- ОС протестирована на Vista и XP
Всем привет.У меня возникли проблемы с настройкой виртуальных хостов.На данный момент у меня есть два сайта.
Вот мой файл vhost.conf:
<VirtualHost *:80>
ServerAdmin me@site.nl
DocumentRoot c:/xampp/htdocs/site1/trunk/
ServerName site1.local
</VirtualHost>
<VirtualHost *:80>
ServerAdmin me@site.nl
DocumentRoot c:/xampp/htdocs/site2/trunk/
ServerName site2.local
</VirtualHost>
И, конечно же, в моем хост-файле у меня есть
127.0.0.1 site1.local
127.0.0.1 site2.local
Я несколько раз перезапускал Apache и браузер.
Вот моя проблема:
http://site1.local работает.Но когда я иду в http://site2.local, я приземляюсь на site1.local.
Любые идеи?
Решение
Пытаться
<VirtualHost "site1.local">
ServerAdmin spam@a1230912##ad#.nl
DocumentRoot c:/xampp/htdocs/site1/trunk/
ServerName site1.local
</VirtualHost>
<VirtualHost "site2.local">
ServerAdmin spam@a1230912##ad#.nl
DocumentRoot c:/xampp/htdocs/site2/trunk/
ServerName site2.local
</VirtualHost>
Вы всегда получаете site1, потому что Apache по умолчанию использует первый.
редактировать
Раскомментировать
#NameVirtualHost *
к
NameVirtualHost *
В вашем httpd.conf
Мой говорит (/etc/httpd/conf/httpd.conf)
126 # Listen: Allows you to bind Apache to specific IP addresses and/or
127 # ports, in addition to the default. See also the <VirtualHost>
128 # directive.
129 #
130 # Change this to Listen on specific IP addresses as shown below to
131 # prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
132 #
133 Listen 127.0.0.1:80
134 NameVirtualHost 127.0.0.1
И мой файл vhost имеет
<VirtualHost "www.whatever.com">
DocumentRoot /var/www/html/whatever/pub
ErrorLog logs/error_log
ServerName www.whatever.com
...
Не связан с StackOverflow