Apache 2.2.16. Виртуальные хосты.Настройка. (Немогу настроить виртуальные хосты)

Обсуждение настройки и работы сервисов, резервирования, сетевых настроек и вопросов безопасности ОС.

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

Аватара пользователя
dimitrius24
Сообщения: 2
ОС: OpenSuse

Apache 2.2.16. Виртуальные хосты.Настройка.

Сообщение dimitrius24 »

Всем доброго времени суток!
У меня OpenSuse 11.2. Поставил себе из рпм апача 2.2.16 и вот мучаюсь,не могу виртуальные хосты настроить!
Посмотрев конфигурационные фалы,я понял, что настройка видётся в /etc/apache2/vhosts.d/ - в этом каталоге нужно создать *.conf - файлик с соответствующим имени твоего будущего хоста.
создал этот файл,www.site.ru.conf,а вот содержимое этого файла:

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

<VirtualHost 127.0.0.1:80>
    ServerAdmin web@master.ru
    ServerName www.site.ru
    DocumentRoot /srv/www/site

    ErrorLog /var/log/apache2/site.ru-error_log
    CustomLog /var/log/apache2/site.ru-access_log combined

    HostnameLookups Off
    UseCanonicalName Off
    ServerSignature On

    ScriptAlias /cgi-bin/ "/srv/www/site.ru/cgi-bin/"

    <Directory "/srv/www/site.ru/cgi-bin">
    AllowOverride None
    Options +ExecCGI -Includes
    Order allow,deny
    Allow from all
    </Directory>

#    <IfModule mod_userdir.c>
#    UserDir public_html
#    Include /etc/apache2/mod_userdir.conf
#    </IfModule>

<Directory "/srv/www/site.ru">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

</VirtualHost>


Результат тот же. Перезагружаю сервер, хост не найден....А вот localhost прекрасно отображается.
Еще,как я понял, нужно править настройки в этих файлах:
/etc/apache2/listen.conf

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

# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports. See also the <VirtualHost> directive.
#
# [url="http://httpd.apache.org/docs-2.2/mod/mpm_common.html#listen"]http://httpd.apache.org/docs-2.2/mod/mpm_common.html#listen[/url]
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
# When we also provide SSL we have to listen to the
# standard HTTP port (see above) and to the HTTPS port
#
# Note: Configurations that use IPv6 but not IPv4-mapped addresses need two
#       Listen directives: "Listen [::]:443" and "Listen 0.0.0.0:443"
#
#Listen 12.34.56.78:80
#Listen 80
#Listen 443

Listen 80


<IfDefine SSL>
    <IfDefine !NOSSL>
    <IfModule mod_ssl.c>

        Listen 443

    </IfModule>
    </IfDefine>
</IfDefine>


# Use name-based virtual hosting
#
# - on a specified address / port:
#
#NameVirtualHost 12.34.56.78:80
#
# - name-based virtual hosting:
#
#NameVirtualHost *:80
#
# - on all addresses and ports. This is your best bet when you are on
#   dynamically assigned IP addresses:
#127.0.0.1 *:80
# Listen for virtual host requests on all IP addresses


/etc/apache2/default-server.conf

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

# Global configuration that will be applicable for all virtual hosts, unless
# deleted here, or overriden elswhere.
#
DocumentRoot "/srv/www/site.ru/"
#
# Configure the DocumentRoot
#
<Directory "/srv/www/site.ru">
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # [url="http://httpd.apache.org/docs-2.2/mod/core.html#options"]http://httpd.apache.org/docs-2.2/mod/core.html#options[/url]
    # for more information.
    Options None
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    AllowOverride None
    # Controls who can get stuff from this server.
    Order allow,deny
    Allow from all
</Directory>

# Aliases: aliases can be added as needed (with no limit). The format is
# Alias fakename realname
#
# Note that if you include a trailing / on fakename then the server will
# require it to be present in the URL.  So "/icons" isn't aliased in this
# example, only "/icons/".  If the fakename is slash-terminated, then the
# realname must also be slash terminated, and if the fakename omits the
# trailing slash, the realname must also omit it.
#
# We include the /icons/ alias for FancyIndexed directory listings.  If you
# do not use FancyIndexing, you may comment this out.
#
Alias /icons/ "/usr/share/apache2/icons/"

<Directory "/usr/share/apache2/icons">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "/srv/www/site.ru/cgi-bin/"

# "/srv/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/srv/www/site.ru/cgi-bin">
    AllowOverride None
    Options +ExecCGI -Includes
    Order allow,deny
    Allow from all
</Directory>

# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.
#
# To disable it, simply remove userdir from the list of modules in APACHE_MODULES
# in /etc/sysconfig/apache2.
#
<IfModule mod_userdir.c>
    # Note that the name of the user directory ("public_html") cannot simply be
    # changed here, since it is a compile time setting. The apache package
    # would have to be rebuilt. You could work around by deleting
    # /usr/sbin/suexec, but then all scripts from the directories would be
    # executed with the UID of the webserver.
    UserDir public_html
    # The actual configuration of the directory is in
    # /etc/apache2/mod_userdir.conf.
    Include /etc/apache2/mod_userdir.conf
    # You can, however, change the ~ if you find it awkward, by mapping e.g.
    # [url="http://www.example.com/users/karl-heinz/"]http://www.example.com/users/karl-heinz/[/url] --> /home/karl-heinz/public_html/
    #AliasMatch ^/users/([a-zA-Z0-9-_.]*)/?(.*) /home/$1/public_html/$2
</IfModule>


# Include all *.conf files from /etc/apache2/conf.d/.
#
# This is mostly meant as a place for other RPM packages to drop in their
# configuration snippet.
#
# You can comment this out here if you want those bits include only in a
# certain virtual host, but not here.
#
Include /etc/apache2/conf.d/*.conf

# The manual... if it is installed ('?' means it won't complain)
Include /etc/apache2/conf.d/apache2-manual?conf


Вот собственно и всё. Уж как я не изголялся,но так и не понял как настроить свой хост.
под виндой я прекрасно и с первого раза настраивал,но тут чёт не получается....
Помогите пожалуйста! :blush:
Спасибо сказали:
Аватара пользователя
sash-kan
Администратор
Сообщения: 13939
Статус: oel ngati kameie
ОС: GNU

Re: Apache 2.2.16. Виртуальные хосты.Настройка.

Сообщение sash-kan »

dimitrius24 писал(а):
08.08.2010 05:14
А вот localhost прекрасно отображается
а в какой адрес резолвится на этой машине www.site.ru?
$ host www.site.ru
?
Писать безграмотно - значит посягать на время людей, к которым мы адресуемся, а потому совершенно недопустимо в правильно организованном обществе. © Щерба Л. В., 1957
при сбоях форума см.блог
Спасибо сказали:
Аватара пользователя
Voral
Сообщения: 1205
ОС: Debian Wheezy (amd64)

Re: Apache 2.2.16. Виртуальные хосты.Настройка.

Сообщение Voral »

Имеет ли права на этот каталог пользователь от которого работает апач (у меня www-data)
dimitrius24 писал(а):
08.08.2010 05:14
DocumentRoot /srv/www/site


dimitrius24 писал(а):
08.08.2010 05:14
ErrorLog /var/log/apache2/site.ru-error_log
CustomLog /var/log/apache2/site.ru-access_log combined

Эти файлы создались?
В них есть что-либо?
То что не убивает нас, делает нас сильнее! © Ницше.
When life puts you in tough situations, don’t say "why me". Just say "try me © ?
Спасибо сказали:
Аватара пользователя
Crazy
Сообщения: 862
Статус: Адепт Дзен.
ОС: Mint, Win7.

Re: Apache 2.2.16. Виртуальные хосты.Настройка.

Сообщение Crazy »

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

<VirtualHost 127.0.0.1:80>

замени на

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

<VirtualHost *:80>

Desipere in loco
Спасибо сказали:
Аватара пользователя
dimitrius24
Сообщения: 2
ОС: OpenSuse

Re: Apache 2.2.16. Виртуальные хосты.Настройка.

Сообщение dimitrius24 »

всё сделал как выше сказали,ничего не помогает........
ну в чём может быть причина?
Пробовал в файл /etc/hosts добавить следующее: 127.0.0.1 www.site.ru - такая же песня,но если 127.0.0.1 заменить на 127.0.0.3 - то всё работает,только с одним исклучением: по имени уже не обратиться,надо только по айпишнику.......
Спасибо сказали:
Аватара пользователя
Crazy
Сообщения: 862
Статус: Адепт Дзен.
ОС: Mint, Win7.

Re: Apache 2.2.16. Виртуальные хосты.Настройка.

Сообщение Crazy »


Desipere in loco
Спасибо сказали: