![]() |
Несколько сайтов на одном IP
Здравствуйте, подскажите что не так делаю нужно сделать на 1ip несколько сайтов (ip/site1, ip/site2 )
1. Debian 7 2. Apache 2.4 Создал директорию под сайт /var/www/test1/public_html и /var/www/test2/public_html конфиг первого (второй делал по аналогии) Скрытый текст
<VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port t$ # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@test1 ServerName test1 ServerAlias www.test1 DocumentRoot /var/www/test1/public_html <Directory /var/www/test1/> Require all granted </Directory> # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet Включаем сайт: $ sudo a2ensite test1 Перезагружаем apache: $ sudo service apache2 restart если зайти по локальному ip все ок если зайти по test1/ тоже работает если зайти по 192.168.0.112/test1/ - Not Found |
никто не сталкивался?
|
Все правильно работает, если хотите чтоб было IP\test1, то надо делать DocumentRoot /var/www. И заходить IP/test1, и IP/test2 соответственно. Но правильней как сейчас настроено, и ходить test1, и test2 соответственно.
|
Цитата:
Потому что при Цитата:
Если хотите, чтобы работал адрес 192.168.0.112/test1/ и прочие, значит нужно указать для "сайта по умолчанию" каталог /var/www/ Код:
<VirtualHost *:80> |
Спасибо большое за ответы!
Цитата:
|
пробовал изменить путь DocumentRoot не пускает по ip
как то так? <VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port t$ # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@test1 ServerName test1 ServerAlias www.test1 DocumentRoot /var/www/ // правим путь <VirtualHost site1:80> //добавляем еще один VirtualHost <Directory "/var/www/site1"> //правим путь к сайту </Directory> </VirtualHost> // закрываем VirtualHost # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet |
если зайти по внешнему ip то отображается страница apache
|
А если указать:
ServerName test1 ServerAlias www.test1 ServerAlias test1/test1 или 192.168.0.112/test1 DocumentRoot /var/www/test1 |
не работает! Может что то не так изначально сделал! Может есть рабочая инструкция перезалью ос и по пробую с нуля настроить?
|
Так, смотрите, сейчас у вас в внутренней сети ходит правильно при настройках:
ServerName test1 ServerAlias www.test1 DocumentRoot /var/www/test1 Теперь чтоб можно было заходить с внешней, вы должны, сделать доменные имена, например test1.ru и test2.org, на любом свободном ДНС или у регистратора имени, например яндекс ДНС или любом другом, зарегистрировать А запись с именем сайта и белым IP. В настройках добавить алиас: ServerAlias www.test1.ru и соответственно ServerAlias www.test2.org После 4 часов, в среднем, можно будет заходить по этим именам. Если же без регистрации и белый IP/test1 заходить надо, тогда настраиваем и внутреннюю сетку, так чтоб ходило серый IP/test1 указав ServerName test1 DocumentRoot /var/www Если я правильно все понял. Просто систему IP, имя, IP\каталог в полной связке ни где не встречал. Когда настраивал свой сервер перечитал куча, в основном советуют связку IP, имя. |
так это и есть имя просто без test1.com я дал имя test1 по ходу так нельзя
|
можно, если есть локальный днс который обработает это имя. Тогда настройте так:
ServerName test1 ServerAlias test1.com ServerAlias www.test1.com DocumentRoot /var/www/test1/ Должно работать со всех сетей. |
Привет всем!
Имеется несколько сайтов на одном сервере (Debian 8). Конфиг следующий: Скрытый текст
Код:
NameVirtualHost *:80 Буквально несколько дней назад, вышеуказанный конфиг работал просто отлично. Но сейчас не работает, при попытке перезапуска apache2, выдает следующее: Код:
Job for apache2.service failed. See 'systemctl status apache2.service' and 'journalctl -xn' for details. Скрытый текст
Код:
ноя 05 10:41:56 forum systemd[1]: Reload failed for LSB: Apache2 web server. В общем Apache ругается на 140 строку. Но там ошибок нет, только подключение модов: Код:
IncludeOptional mods-enabled/*.load
|
Время: 08:03. |
Время: 08:03.
© OSzone.net 2001-