Javascript-форум (https://javascript.ru/forum/)
-   Серверные языки и технологии (https://javascript.ru/forum/server/)
-   -   Путь к сайту test.ru (https://javascript.ru/forum/server/52864-put-k-sajjtu-test-ru.html)

usa-1450 10.01.2015 15:00

Путь к сайту test.ru
 
Локалхост и сайт лежит в папке htdocs по адресу
F:/apache/htdocs/


НЕ получается заходить на сайт введя просто test.ru. Чтобы зайти на сайт приходится вводить http://test.ru/test.ru/www/

и тогда запускается сайт, в файле хостов, ввел такое и все равно не работает даже при том, что прописал весь путь в DocumentRoot. Как правильно прописать путь?

Код:

# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#

<VirtualHost *:80>
DocumentRoot "F:/apache/htdocs/localhost/www"
ServerName localhost
ErrorLog "F:/apache/htdocs/localhost/error.log"
CustomLog "F:/apache/localhost/access.log" common
</VirtualHost>

<VirtualHost *:80>
# Папка, в которой будет корень вашего хоста.
DocumentRoot "F:/apache/htdocs/test.ru/www"
# Домен по которому вы сможете обращаться к виртуальному хосту.
ServerName test.ru
# Алиас (добавочное имя) домена.
ServerAlias http://www.test.ru/
# Файл, в который будут записываться ошибки.
ErrorLog "F:/apache/htdocs/error.log"
# Файл журнала доступа к хосту.
CustomLog "F:/apache/htdocs/access.log" common
</VirtualHost>

Тут лежит файл test.ru.
Вот содержимое файла хостс и все равно не хочет.

Код:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97    rhino.acme.com          # source server
#      38.25.63.10    x.acme.com              # x client host
      127.0.0.1        test.ru 
          127.0.0.1        www.test.ru
          127.0.0.1        localhost

Тут лежит
Заметил странную вещь. Убрал в файле хостов такую строку:
Код:

# Папка, в которой будет корень вашего хоста.
DocumentRoot "F:/apache/htdocs/test.ru/www"

И все равно чтобы запустить сайт приходится вводить такое в браузере http://test.ru/test.ru/www/ вместо
http://test.ru/ Как исправить?

bes 10.01.2015 15:14

у тебя DocumentRoot задан в корне httpd.conf, там и меняй
либо создаёшь вирутальный хост с новым ip и задаёшь соответствие в файле C:\Windows\System32\drivers\etc\hosts

Vlasenko Fedor 10.01.2015 15:59

usa-1450 Для изучения поставь Open Server :)
и будет тебе счастье и + полезные плюшки

usa-1450 10.01.2015 19:43

Скачать Open Server я могу в любой момент, я хочу разобраться.
Если прописать строку DocumentRoot "F:/apache/htdocs/test.ru/www" в httpd.conf тогда запускается сайт по ссылке test.ru, но мне нужно чтобы несколько сайтов можно было запускать на сервере. Как так сделать?


Когда правлю после этого DocumentRoot в файл хостов httpd-vhosts.conf, любой сервер какой бы не подправил и любой путь какой бы не указал в DocumentRoot, все равно все обращение идет к сайту test.ru который указал в httpd.conf, на изображении выше.
Мне нужно чтобы несколько серверов работало на ПК, как прописать чтобы несколько серверов работало и чтобы они запускались нормально? Например test.ru, super.ru, crazy.ru и нормально их можно было бы вводить.

bes 10.01.2015 19:49

Цитата:

Сообщение от usa-1450
Когда правлю после этого DocumentRoot в файл хостов httpd-vhosts.conf, любой сервер какой бы не подправил и любой путь какой бы не указал в DocumentRoot, все равно все обращение идет к сайту test.ru который указал в httpd.conf, на изображении выше.
Мне нужно чтобы несколько серверов работало на ПК, как прописать чтобы несколько серверов работало?

read once more
Цитата:

Сообщение от bes
либо создаёшь вирутальный хост с новым ip и задаёшь соответствие в файле C:\Windows\System32\drivers\etc\hosts


usa-1450 10.01.2015 20:43

Вот файл hosts c диска С:



Вы имеете такие же 3 копии создать hosts1, hosts2, hosts3 или вместо
127.0.0.1 www.test.ru
Выдумать и написать например
127.0.0.3 www.crazy.ru
Про это речь идет?

bes 10.01.2015 20:46

Цитата:

Сообщение от usa-1450
Вы имеете такие же 3 копии создать hosts1, hosts2, hosts3 или вместо
127.0.0.1 www.test.ru
Выдумать и написать например
127.0.0.3 www.crazy.ru
Про это речь идет?

да, выдумать и дописать в hosts
для 127.0.0.3 создать виртуальный хост в httpd.conf

usa-1450 10.01.2015 22:16

В Файле хостс я решил к примеру создать другой хост test2.ru, вот дописываю его в файле хостов:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97      rhino.acme.com          # source server
#      38.25.63.10       x.acme.com              # x client host
       127.0.0.1         test.ru  
	   127.0.0.1         www.test.ru
	   127.0.0.2         www.test2.ru
	   127.0.0.1         localhost


В файле httpd.conf добавлять виртуальный хост или в файле httpd-vhosts.conf все-таки?
В файле httpd-vhosts.conf такое содержимое:

# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#

<VirtualHost *:80>
DocumentRoot "F:/apache/htdocs/localhost/www" 
ServerName localhost
ErrorLog "F:/apache/htdocs/localhost/error.log"
CustomLog "F:/apache/localhost/access.log" common
</VirtualHost>

<VirtualHost *:80>
# Папка, в которой будет корень вашего хоста.
DocumentRoot "F:/apache/htdocs/test.ru/www" 
# Домен по которому вы сможете обращаться к виртуальному хосту.
ServerName test.ru
ServerAlias www.test.ru
# Файл, в который будут записываться ошибки.
ErrorLog "F:/apache/htdocs/error.log"
# Файл журнала доступа к хосту.
CustomLog "F:/apache/htdocs/access.log" common
</VirtualHost>

<VirtualHost *:80>
# Папка, в которой будет корень вашего хоста.
DocumentRoot "F:/apache/htdocs/test2.ru/www" 
# Домен по которому вы сможете обращаться к виртуальному хосту.
ServerName test.ru
ServerAlias www.test.ru
# Файл, в который будут записываться ошибки.
ErrorLog "F:/apache/htdocs/error.log"
# Файл журнала доступа к хосту.
CustomLog "F:/apache/htdocs/access.log" common
</VirtualHost>


Только в самом файле httpd.conf в директиве DocumentRoot какой все же путь указать чтобы все три сайта localhost, test.ru, test2.ru запускались по отдельности?

bes 10.01.2015 22:19

http://httpd.apache.org/docs/2.4/vhosts/ip-based.html

usa-1450 10.01.2015 23:34

Сделал как там в документации написано, прописал так:
# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#

<VirtualHost 127.0.0.1:80>
DocumentRoot "F:/apache/htdocs/localhost/www" 
ServerName localhost
ErrorLog "F:/apache/htdocs/localhost/error.log"
CustomLog "F:/apache/localhost/access.log" common
</VirtualHost>

<VirtualHost 127.0.0.1:80>
# Папка, в которой будет корень вашего хоста.
DocumentRoot "F:/apache/htdocs/test.ru/www" 
# Домен по которому вы сможете обращаться к виртуальному хосту.
ServerName test.ru
ServerAlias www.test.ru
# Файл, в который будут записываться ошибки.
ErrorLog "F:/apache/htdocs/error.log"
# Файл журнала доступа к хосту.
CustomLog "F:/apache/htdocs/access.log" common
</VirtualHost>

<VirtualHost 127.0.0.2:80>
# Папка, в которой будет корень вашего хоста.
DocumentRoot "F:/apache/htdocs/test2.ru/www" 
# Домен по которому вы сможете обращаться к виртуальному хосту.
ServerName test2.ru
ServerAlias www.test2.ru
# Файл, в который будут записываться ошибки.
ErrorLog "F:/apache/htdocs/error.log"
# Файл журнала доступа к хосту.
CustomLog "F:/apache/htdocs/access.log" common
</VirtualHost>


Файл хостс:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97      rhino.acme.com          # source server
#      38.25.63.10       x.acme.com              # x client host
       127.0.0.1         test.ru  
	   127.0.0.1         www.test.ru
	   127.0.0.2         test2.ru
	   127.0.0.2         www.test2.ru
	   127.0.0.1         localhost

Запускаю test2.ru и выпадает такое вместо сайта
Index of /

localhost/
phpmyadmin/
test.ru/
test2.ru/


http://www.fotolink.su/pic_b/336bb32...39f42c0b41.jpg

bes 10.01.2015 23:41

Цитата:

Сообщение от usa-1450
Запускаю test2.ru и выпадает такое вместо сайта

http://www.fotolink.su/v.php?id=336b...731939f42c0b41

а ты чего хотел? всё это конфигурируется, читай доку

usa-1450 11.01.2015 00:03

По этой ссылке что вы дали нет информации что нужно исправить.
Если прописать в httpd.conf строку:

DocumentRoot "F:/apache/htdocs/test2.ru/www"


# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "F:/apache/htdocs/test2.ru/www" 

<Directory "F:/apache">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLink
...............................................
.....................


Тогда все будет пучком и введя в браузер test2.ru загрузится сайт, но проблема в том что все остальные сайты test.ru, localhost будет равносильно что я введу test2.ru.
Что делать? Как каждый сайт выводить с его индексным файлом? Я не могу понять какую строку ввести в файле httpd.conf чтобы какждый сайт запускался с его индексным файлом.

bes 11.01.2015 00:17

Цитата:

Сообщение от usa-1450
По этой ссылке что вы дали нет информации что нужно исправить.

так лучше?
http://httpd.apache.org/docs/

Цитата:

Сообщение от usa-1450
Тогда все будет пучком и введя в браузер test2.ru загрузится сайт, но проблема в том что все остальные сайты test.ru, localhost будет равносильно что я введу test2.ru.
Что делать? Как каждый сайт выводить с его индексным файлом? Я не могу понять какую строку ввести в файле httpd.conf чтобы какждый сайт запускался с его индексным файлом.

есть DirectoryIndex, есть Options, есть другие директивы, есть книга "Администрирование Apache" в переводе, неужели гугл, усеянный информацией по этой теме, молчит?

usa-1450 11.01.2015 00:32

Я не знаю как подправить чтобы каждый сайт запускался по отдельности (в гугле искал инфо и в документации смотрел ничего не могу найти по этому поводу), кто-то может подсказать? Делал все по правилам и только один сайт запускается если прописать в DocumentRoot путь к одному из них, как указать?

bes 11.01.2015 00:36

Цитата:

Сообщение от usa-1450
Я не знаю как подправить чтобы каждый сайт запускался по отдельности (в гугле искал инфо и в документации смотрел ничего не могу найти по этому поводу), кто-то может подсказать? Делал все по правилам и только один сайт запускается если прописать в DocumentRoot путь к одному из них, как указать?

я тебе ключевые слова-директивы обозначил, прогугли их и будет тебе счастье

usa-1450 11.01.2015 01:26

Директива options ну она ни как не решает проблему. Проблема в том что все сайты ссылаются на один.

bes 11.01.2015 02:38

Цитата:

Сообщение от usa-1450
Директива options ну она ни как не решает проблему. Проблема в том что все сайты ссылаются на один.

речь шла про DirectoryIndex, у меня работает (как с разными ip, так и с одинаковыми ip, но разными ServerName)
там бывают затыки с AllowOverride, например, когда AllowOverride All, а DirectoryIndex задан как для директории в httpd.conf, так и в .htaccess (в общем, для проверки добавь для директорий AllowOverride None или удали .htaccess-ы)

usa-1450 11.01.2015 13:19

Цитата:

а DirectoryIndex задан как
Он у меня в файле httpd.conf такой:
<IfModule dir_module>
    DirectoryIndex index.php index.html 
</IfModule>


Поудалял .htaccess который лежал рядом с индексным файлом.В файле httpd.conf строку AllowOverride None исправил на AllowOverride All, сохранил и перезагрузил сервер и как вываливался каталог так и вываливается, не могу просто ввести test.ru чтобы запустился сайт, вываливается такое:

Index of /

localhost/
phpmyadmin/
test.ru/
test2.ru/

bes 11.01.2015 14:17

Цитата:

Сообщение от usa-1450
Поудалял .htaccess который лежал рядом с индексным файлом.В файле httpd.conf строку AllowOverride None исправил на AllowOverride All, сохранил и перезагрузил сервер и как вываливался каталог так и вываливается, не могу просто ввести test.ru чтобы запустился сайт, вываливается такое

деньги уже пора с тебя брать ;)

Цитата:

Сообщение от bes
у меня работает (как с разными ip, так и с одинаковыми ip, но разными ServerName)

ниже вариант с разными ServerName

httpd.conf
<VirtualHost 127.0.0.2:80>
    ServerAdmin webmaster&www1.example.com
    DocumentRoot C:\Apache24\htdocs\test
    ServerName test.ru
    #ErrorLog /www/logs/www1/error_log
    #CustomLog /www/logs/www1/access_log combined
	<Directory "C:\Apache24\htdocs\test">
		DirectoryIndex test.html
	</Directory>
</VirtualHost>
<VirtualHost 127.0.0.2:80>
    ServerAdmin webmaster&www1.example.com
    DocumentRoot C:\Apache24\htdocs\test2
    ServerName test2.ru
    #ErrorLog /www/logs/www1/error_log
    #CustomLog /www/logs/www1/access_log combined
	<Directory "C:\Apache24\htdocs\test2">
		DirectoryIndex index.html
		AllowOverride All
	</Directory>
</VirtualHost>


в .htaccess DirectoryIndex не задан

hosts
127.0.0.2 test.ru
127.0.0.2 test2.ru


Всё работает! :yes:

PS: @ в почтовом адресе заменил на &, редактор здесь падает от неё

usa-1450 17.01.2015 18:26

файл хостс:
Код:

  102.54.94.97      rhino.acme.com          # source server
#      38.25.63.10      x.acme.com              # x client host
      127.0.0.1        test.ru 
          127.0.0.1        www.test.ru
          127.0.0.2        test2.ru
          127.0.0.2        www.test2.ru
          127.0.0.1        localhost

Файл httpd-vhosts.conf:
Код:

# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#

<VirtualHost 127.0.0.2:80>
# Папка, в которой будет корень вашего хоста.
DocumentRoot "F:/apache/htdocs/test.ru/www"
# Домен по которому вы сможете обращаться к виртуальному хосту.
ServerName test.ru
ServerAlias www.test.ru
# Файл, в который будут записываться ошибки.
ErrorLog "F:/apache/htdocs/error.log"
# Файл журнала доступа к хосту.
CustomLog "F:/apache/htdocs/access.log" common
<Directory "F:\apache\htdocs\test.ru>
  DirectoryIndex index.php
  AllowOverride All
</Directory>
</VirtualHost>

<VirtualHost 127.0.0.2:80>
# Папка, в которой будет корень вашего хоста.
DocumentRoot "F:/apache/htdocs/test2.ru/www"
# Домен по которому вы сможете обращаться к виртуальному хосту.
ServerName test2.ru
ServerAlias www.test2.ru
# Файл, в который будут записываться ошибки.
ErrorLog "F:/apache/htdocs/error.log"
# Файл журнала доступа к хосту.
CustomLog "F:/apache/htdocs/access.log" common
<Directory "F:\apache\htdocs\test2.ru>
  DirectoryIndex index.php
  AllowOverride All
</Directory>
</VirtualHost>

Подправил так выше и ничего не изменилось, приходится все равно писать по тупому http://test.ru/test.ru/www/ чтобы запустился сайт, кошмар. Что нужно исправить?

bes 17.01.2015 18:32

а теперь посмотри на мой пример и найди отличия

usa-1450 17.01.2015 20:37

У вас все прописано как у меня, у вас просто свои пути где лежит сайт у меня свои, все по примеру и не работает, странно как-то.

bes 17.01.2015 20:41

Цитата:

Сообщение от usa-1450
У вас все прописано как у меня, у вас просто свои пути где лежит сайт у меня свои, все по примеру и не работает, странно как-то.

у меня для DocumentRoot свойства в тегах Directory задаются, у тебя - нет, и в hosts не то

usa-1450 20.01.2015 02:34

Вложений: 1
Решил удалить файл httpd.conf и скопировал чистый httpd.conf (httpd-2.4.10-win32-VC11.zip) с http://www.apachelounge.com/download/
Подкорректировал файл httpd.conf, готовый файл в архиве httpd.zip
Подкорректировал httpd-vhosts.conf
Код:

# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#

<VirtualHost 127.0.0.1:80>
# Папка, в которой будет корень вашего хоста.
DocumentRoot "F:/apache/htdocs/localhost/www"
# Домен по которому вы сможете обращаться к виртуальному хосту.
ServerName localhost
ServerAlias www.localhost.ru
# Файл, в который будут записываться ошибки.
ErrorLog "F:/apache/htdocs/error.log"
# Файл журнала доступа к хосту.
CustomLog "F:/apache/htdocs/access.log" common
</VirtualHost>

<VirtualHost 127.0.0.2:80>
# Папка, в которой будет корень вашего хоста.
DocumentRoot "F:/apache/htdocs/test.ru/www"
# Домен по которому вы сможете обращаться к виртуальному хосту.
ServerName test.ru
ServerAlias www.test.ru
# Файл, в который будут записываться ошибки.
ErrorLog "F:/apache/htdocs/error.log"
# Файл журнала доступа к хосту.
CustomLog "F:/apache/htdocs/access.log" common
</VirtualHost>

<VirtualHost 127.0.0.3:80>
# Папка, в которой будет корень вашего хоста.
DocumentRoot "F:/apache/htdocs/test2.ru/www"
# Домен по которому вы сможете обращаться к виртуальному хосту.
ServerName test2.ru
ServerAlias www.test2.ru
# Файл, в который будут записываться ошибки.
ErrorLog "F:/apache/htdocs/error.log"
# Файл журнала доступа к хосту.
CustomLog "F:/apache/htdocs/access.log" common

</VirtualHost>

Подкорректировал c:\Windows\System32\drivers\etc\hosts
Код:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97      rhino.acme.com          # source server
#      38.25.63.10      x.acme.com              # x client host
          127.0.0.1        localhost 
          127.0.0.1        www.localhost.ru
      127.0.0.2        test.ru 
          127.0.0.2        www.test.ru
          127.0.0.3        test2.ru
          127.0.0.3        www.test2.ru

К моему удивлению заработал сайт простым запросом test.ru и test2.ru, но к сожалению при вводе localhost сразу не запускается сайт, а выдает такую траблy:
Код:

Index of /

access.log
error.log
localhost/
phpmyadmin/
test.ru/
test2.ru/

Приходится вводить http://localhost/localhost/www/ Как исправить?


Часовой пояс GMT +3, время: 01:25.