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


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