PDA

Показать полную графическую версию : [решено] VirtualHosts


Artem-Samsung
03-10-2008, 02:23
Не получается настроить. Точнее насроить у меня не с первой попытки, и сделать что бы
при /etc/init.d/apache2 restart
ошибок не выводилось:

Syntax OK
Shutting down httpd2 (waiting for all children to terminate) done
Starting httpd2 (prefork) done


Значит настройки в httpd.conf
Дописал такое:


Listen 80
NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /srv/www/htdocs
ServerName www.deykun.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /srv/www/xtf
ServerName www.centao.co.cc
<Directory "/srv/www/xtf">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>




Вообщем я дописывал еще один сайт, но от него такой же эффект.
Следующий:
Все адреса ведут на сайт, который был раньше и до настройки Виртуального Хостинга.
www.deykun.com

Даже не знаю что дальше делать. Подскажите.

ruslandh
03-10-2008, 05:09
А где ошибки ?

Artem-Samsung
03-10-2008, 10:05
А где ошибки ? »
Ошибка в том, что отображается один и тот же сайт:
www.deykun.com
www.centao.co.cc, имеет разные совсем другую директорию...

ruslandh
03-10-2008, 10:43
https://forum.web-hack.ru/index.php?showtopic=71962

Artem-Samsung
03-10-2008, 16:35
Сделал как написано:

NameVirtualHost *

<VirtualHost *>
DocumentRoot /srv/www/htdocs
ServerName www.deykun.com
</VirtualHost>

<VirtualHost *>
DocumentRoot /srv/www/xtf
ServerName www.centao.co.cc
</VirtualHost>

Резльтат вот здесь на лицо - www.centao.co.cc
Forbidden
Атрибут на папку /srv/www/xtf - 0777

:help:

ruslandh
03-10-2008, 23:25
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.

Вообще-то правильнее логи смотреть - к какой папке или файлу нет acces`а
Ну, и желательно
ls -l /srv/www/xtf/*

Artem-Samsung
04-10-2008, 00:22
NameVirtualHost *

<VirtualHost *>
DocumentRoot /srv/www/htdocs
ServerName www.deykun.com
</VirtualHost>

<VirtualHost *>
DocumentRoot /srv/www/test
ServerName www.my.deykun.com
</VirtualHost>

Тестирую с мобилки www.my.deykun.com

[Fri Oct 03 16:22:34 2008] [notice] caught SIGTERM, shutting down
[Fri Oct 03 16:22:34 2008] [notice] Apache/2.2.3 (Linux/SUSE) configured -- resuming normal operations
[Fri Oct 03 16:23:33 2008] [error] [client 91.203.96.28] client denied by server configuration: /srv/www/test/
[Fri Oct 03 16:23:33 2008] [error] [client 91.203.96.28] client denied by server configuration: /srv/www/test/favicon.ico, referer: http://www.my.deykun.com/

soltek:~ # ls -l /srv/www/test/*
-rw-r--r-- 1 artemhp users 5892 Oct 3 12:47 /srv/www/test/index.html

/srv/www/test/images:
total 344
-rw-r--r-- 1 artemhp users 23040 Oct 3 08:47 Thumbs.db
-rw-r--r-- 1 artemhp users 15779 Oct 3 08:49 img_01.png
-rw-r--r-- 1 artemhp users 922 Oct 3 08:49 img_02.png
-rw-r--r-- 1 artemhp users 128902 Oct 3 08:49 img_03.png
-rw-r--r-- 1 artemhp users 183 Oct 3 08:49 img_04.png
-rw-r--r-- 1 artemhp users 11538 Oct 3 08:49 img_05.png
-rw-r--r-- 1 artemhp users 908 Oct 3 08:49 img_06.png
-rw-r--r-- 1 artemhp users 952 Oct 3 08:49 img_07.png
-rw-r--r-- 1 artemhp users 186 Oct 3 08:49 img_08.png
-rw-r--r-- 1 artemhp users 120247 Oct 3 08:49 img_09.png
-rw-r--r-- 1 artemhp users 175 Oct 3 08:49 img_10.png
-rw-r--r-- 1 artemhp users 649 Oct 3 08:49 img_11.png
-rw-r--r-- 1 artemhp users 968 Oct 3 08:49 img_12.png
-rw-r--r-- 1 artemhp users 1082 Oct 3 08:49 img_13.png

dmitryst
04-10-2008, 11:57
У меня так:
<VirtualHost *:80>
ServerAdmin root@localhost
ServerName 4site.local
ServerAlias www.4site.local
DocumentRoot "/srv/www/4site"
ScriptAlias /cgi-bin/ "/srv/www/4site/cgi-bin/"
ErrorLog /srv/www/4site/4site-errors_log
CustomLog /srv/www/4site/4site-access_log common
<Directory /srv/www/4site/>
Options Includes Indexes +FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>

</VirtualHost> <VirtualHost *:80>
ServerAdmin root@localhost
ServerName simple.local
ServerAlias www.simple.local
DocumentRoot "/srv/www/simple.local"
ScriptAlias /cgi-bin/ "/srv/www/simple.local/cgi-bin/"
ErrorLog /srv/www/simple.local/simple-errors_log
CustomLog /srv/www/simple.local/simple-access_log common
<Directory /srv/www/simple.local/>
Options Includes Indexes
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
В файле /etc/hosts сделаны соответствующие записи о хостах. Кстати, в случае чего, будет отображаться первый виртуальный хост. Опция индексов обязательна.

Artem-Samsung
04-10-2008, 16:52
Хм.. а вот по поводу hosts ?
То у я прописал следующее:
Это правильно?

127.0.0.1 localhost
127.0.0.1 www.centao.co.cc
127.0.0.1 centao.co.cc
127.0.0.1 my.deykun.com
127.0.0.1 www.my.deykun.com

dmitryst
04-10-2008, 18:28
Artem-Samsung, а в конфиге апача в секции Listen что написано? В вашем случае должно быть "LIsten 127.0.0.1 80". А индексы - впишите :)

Artem-Samsung
04-10-2008, 18:38
NameVirtualHost *

<VirtualHost *:80>
DocumentRoot /srv/www/htdocs
ServerName www.deykun.com
<Directory /srv/www/htdocs/>
Options Includes Indexes +FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /srv/www/test
ServerName www.my.deykun.com
<Directory /srv/www/test/>
Options Includes Indexes +FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>



Было Listen 80
Сделал Listen 127.0.0.1:80

soltek:~ # /etc/init.d/apache2 restart
[Sat Oct 04 10:47:38 2008] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
[Sat Oct 04 10:47:38 2008] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
Syntax OK
Shutting down httpd2 (waiting for all children to terminate) done
Starting httpd2 (prefork) [Sat Oct 04 10:47:39 2008] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
[Sat Oct 04 10:47:39 2008] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
done

Artem-Samsung
04-10-2008, 19:05
NameVirtualHost 192.168.0.107:80

<VirtualHost 192.168.0.107:80>
DocumentRoot /srv/www/deykun
ServerName www.deykun.com
<Directory /srv/www/htdocs/>
Options Includes Indexes +FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.107:80>
DocumentRoot /srv/www/test
ServerName www.my.deykun.com
<Directory /srv/www/test/>
Options Includes Indexes +FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>




Ура :) Начало что то подхватывать

woooohooo :) Все заработало.
Вот только меня смутило, что приналичии index.html открывалась вся папка в браузере целеком. т.е. стартовую не загружая автоматом, а когда переименовал в .php то заработало.

Потом каким образом я могу заходить на эти сайты в из своей сети?
Я вот к примеру не могу зайти напрямик на deykun.com, а нужно было писать айпи компа в сети 192.168.0.107.
Решилась было проблемка, прописав в Windows XP в файле hosts присвоив домену deykun.com айпи 192.168.0.107
Ну вот теперь туда дописал еще и www.my.deykun.com
И по www.my.deykun.com выдает тот же сайт что и на deykun.com. А извне сети, все нормально.

Как решить? ДНС отдельно для одного компа что то желания делать нету.

dmitryst
10-10-2008, 14:02
Вот только меня смутило, что приналичии index.html открывалась вся папка в браузере целеком. т.е. стартовую не загружая автоматом, а когда переименовал в .php то заработало. »
Ну так у вас в основном конфиге наверняка написано -
DirectoryIndex index.php

То есть если есть файл index.php, то автоматом откроется он. В пишите в эту секцию index.html (с пробелом после index.php), и будет загружаться index.html, если нет index.php. Короче, будут грузиться указанные файлы в порядке очередности, если ни одного из них не будет, будет открыт список файлов в папке.
Пример:
DirectoryIndex index.html index.php tracker.cgi

выдает тот же сайт что и на deykun.com »
А в hosts вашего сервера что записано? Дайте его сюда :)

Мой hosts клиентских виндовс-машин:

127.0.0.1 localhost
192.168.1.100 www.mysite.lan
192.168.1.100 mysite.lan
192.168.1.100 4site.local
192.1681.100 www.4site.local
192.168.1.100 control.local
192.168.1.100 simple.local
192.168.1.100 www.simple.local

Мой hosts сервера (192,168,1,100)
::1 localhost localhost.localdomain
127.0.0.1 localhost localhost.localdomain
192.168.1.100 www.mysite.lan
192.168.1.100 mysite.lan
192.168.1.100 4site.local
192.1681.100 www.4site.local
192.168.1.100 control.local
192.168.1.100 simple.local
192.168.1.100 www.simple.local

В конфиге апача должно быть Listen 80, иначе он не поймет, что от него надо




© OSzone.net 2001-2012