Решено: настройка vhosts.conf (сломал голову)

Модераторы: Skull, Модераторы разделов

Grig
Сообщения: 81
ОС: Ubuntu 9.10

Решено: настройка vhosts.conf

Сообщение Grig »

Здравствуйте! Вроде и документации много и форум прошустрил, все равно не получается((
Уж и не знаю что делать.
vhosts.conf
<VirtualHost test1.ru>
ServerAdmin gpa5@yandex.ru
DocumentRoot /home/grig/www/test1/www
ServerName www.test1.ru
ServerAlias test1.ru
AddType application/x-httpd-php .php
ErrorLog /var/log/httpd2/test1.ru-error_log
CustomLog /var/log/httpd2/test1.ru-access_log common
DirectoryIndex index.html index.php index.htm
AddDefaultCharset off
#AddDefaultCharset KOI8-R


<Directory /home/grig/www/test1/www>

Options -Indexes FollowSymLinks
DirectoryIndex index.php index.htm index.html
AllowOverride None
Order allow,deny
Allow from all

</Directory>
</VirtualHost>


/etc/hosts
127.0.0.1 localhost.localdomain localhost
127.0.0.4 www.test1.ru test1.ru


при запуске сервера набираю в браузере http://127.0.0.4/ или http://test1.ru/
он меня отсылает на содержимое localhost
То есть берет index.html из папки /var/www/apache2/html

подскажите, как его правильно настроить?
Спасибо сказали:
BezrukovA
Сообщения: 12
ОС: altcompact 3.0

Re: Решено: настройка vhosts.conf

Сообщение BezrukovA »

Я бы не стал использовать ip = 127.0.0.4, т.к. он возможно в Linux специальным образом обрабатывается.
> whois 127.0.0.4
...
NetRange: 127.0.0.0 - 127.255.255.255
CIDR: 127.0.0.0/8
NetName: LOOPBACK
NetHandle: NET-127-0-0-0-1
Parent:
NetType: IANA Special Use
Comment: Please see RFC 3330 for additional information.
RegDate:
Updated: 2002-10-14
....
Спасибо сказали:
Grig
Сообщения: 81
ОС: Ubuntu 9.10

Re: Решено: настройка vhosts.conf

Сообщение Grig »

А разницы нет... Это я айпишники начал менять от безысходняковости(
Спасибо сказали:
Аватара пользователя
sh0ckfile
Сообщения: 168
Статус: Cirno fan
ОС: Ubuntu/WinXP

Re: Решено: настройка vhosts.conf

Сообщение sh0ckfile »

Почитайте документацию по доменным именам вообще. То, что вы типа повесили апач на test1.ru, не значит, что он будет откликаться - ваш комп ведь не раздаёт домены из зоны .ru. Поднимите локальный dns и крутите вначале его, а потом уже виртуальные хосты.
"Чтобы быть человеком, нужно им какое-то время не быть" ©Ю.А.Бригадир
Registered Linux user #437143.
Спасибо сказали:
Grig
Сообщения: 81
ОС: Ubuntu 9.10

Re: Решено: настройка vhosts.conf

Сообщение Grig »

поменял все, да и раньше так было.
vhosts.conf

Код:

<VirtualHost test1> ServerAdmin gpa5@yandex.ru DocumentRoot /home/gpa/www/test1/www ServerName test1 ServerAlias test1 AddType application/x-httpd-php .php ErrorLog /var/log/httpd2/test1-error_log CustomLog /var/log/httpd2/test1-access_log common DirectoryIndex index.html index.php index.htm AddDefaultCharset off #AddDefaultCharset KOI8-R <Directory /home/gpa/www/test1/www> Options -Indexes FollowSymLinks DirectoryIndex index.php index.htm index.html AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost>


/etc/hosts

Код:

127.0.0.1 localhost.localdomain localhost 127.0.0.1 test1


Все равно не помогает, ссылается http://test1/ на главный сайт(localhost)
Спасибо сказали:
headcrab
Сообщения: 175
ОС: Windows 7

Re: Решено: настройка vhosts.conf

Сообщение headcrab »

Уберите из ./conf/httpd.conf все что касается ServerName, DocumentRoot и прочей лаже относящейся к хосту по умолчанию.
Отредактируйте /etc/hosts
Добавьте строчку : 127.0.0.1 localhost <имя_домена_первого_виртуалхоста> <имя_домена_второго_виртуалхоста>
Либо поднимайте DNS, т.к. /etc/hosts касается только локальной машины.
Затем редактируйте ./conf/vhosts.conf
Создайте нужное кол-во виортуальных хостов по шаблону:

Код: Выделить всё

NameVirtualHost *
<VirtualHost *>
    ServerName site1.ru
    DocumentRoot <путь к каталогу документов>

</VirtualHost>

<VirtualHost *>
    ServerName site2.ru
    DocumentRoot <путь к каталогу документов>

</VirtualHost>


Вот мой конфиг vhosts.conf

Код: Выделить всё

# cat /var/www/conf/vhosts.conf
<Directory />
    AllowOverride All
</Directory>

NameVirtualHost *

<VirtualHost *>
    ServerName *
    DocumentRoot /var/www/vhosts/default/www
    ErrorLog /var/www/vhosts/default/www_logs/error_log
    CustomLog /var/www/vhosts/default/www_logs/custom_log common
</VirtualHost>


<VirtualHost 127.0.0.2>
    ServerName mynix.blogsite.org
    ServerAlias mynix.blogsite.org
    DocumentRoot /var/www/vhosts/127.0.0.2/www
    ErrorLog /var/www/vhosts/127.0.0.2/www_logs/error_log
    CustomLog /var/www/vhosts/127.0.0.2/www_logs/custom_log common
</VirtualHost>

<VirtualHost 192.168.0.1>
    ServerName gate.mynix
    ServerAlias gate
    DocumentRoot /var/www/vhosts/gate.mynix/www
    ErrorLog /var/www/vhosts/gate.mynix/www_logs/error_log
    CustomLog /var/www/vhosts/gate.mynix/www_logs/custom_log common
#    <Directory />
#       Order deny,allow
#       Deny from all
#       Allow from 192.168.0.0/24
#    </Directory>

</VirtualHost>


<VirtualHost 10.128.109.57>
    ServerName 10.128.109.57

    DocumentRoot /var/www/vhosts/anthill/www
    ErrorLog /var/www/vhosts/anthill/www_logs/error_log
    CustomLog /var/www/vhosts/anthill/www_logs/custom_log common
    <Directory />
        AllowOverride All
        Order deny,allow
        Deny from all
        Allow from 10.0.0.0/8 172.16.0.0/12
    </Directory>

</VirtualHost>
Спасибо сказали:
Grig
Сообщения: 81
ОС: Ubuntu 9.10

Re: Решено: настройка vhosts.conf

Сообщение Grig »

Огромное человеческое спасибо!
Спасибо сказали: