Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.arcetri.astro.it/manual/de/vhosts/ip-based.html
Дата изменения: Mon Jan 21 19:44:30 2013 Дата индексирования: Fri Feb 28 06:26:29 2014 Кодировка: Поисковые слова: п п п п п п п п п |
Apache HTTP Server Version 2.2
IP-based virtual hosting is a method to apply different directives based on the IP address and port a request is received on. Most commonly, this is used to serve different websites on different ports or interfaces.
In many cases, name-based virtual hosts are more convenient, because they allow many virtual hosts to share a single address/port. See Name-based vs. IP-based Virtual Hosts to help you decide.
As the term IP-based indicates, the server must have a different IP address/port combination for each IP-based virtual host. This can be achieved by the machine having several physical network connections, or by use of virtual interfaces which are supported by most modern operating systems (see system documentation for details, these are frequently called "ip aliases", and the "ifconfig" command is most commonly used to set them up), and/or using multiple port numbers.
In the terminology of Apache HTTP Server, using a single IP address but multiple TCP ports, is also IP-based virtual hosting.
There are two ways of configuring apache to support multiple
hosts. Either by running a separate httpd
daemon for
each hostname, or by running a single daemon which supports all the
virtual hosts.
Use multiple daemons when:
User
, Group
, Listen
, and ServerRoot
settings.Listen
to the "wildcard"
address, or to specific addresses. So if you have a need to
listen to a specific address for whatever reason, then you
will need to listen to all specific addresses. (Although one
httpd
could listen to N-1 of the addresses, and another could
listen to the remaining address.)Use a single daemon when:
Create a separate httpd
installation for each
virtual host. For each installation, use the Listen
directive in the
configuration file to select which IP address (or virtual host)
that daemon services. e.g.
Listen 192.168.0.1:80
It is recommended that you use an IP address instead of a hostname (see DNS caveats).
For this case, a single httpd
will service
requests for the main server and all the virtual hosts. The VirtualHost
directive
in the configuration file is used to set the values of ServerAdmin
, ServerName
, DocumentRoot
, ErrorLog
and TransferLog
or CustomLog
configuration directives to different values for each virtual
host. e.g.
<VirtualHost 192.168.0.1:80>
ServerAdmin webmaster@smallco.example.com
DocumentRoot /groups/smallco/www
ServerName smallco.example.com
ErrorLog /groups/smallco/logs/error_log
TransferLog /groups/smallco/logs/access_log
</VirtualHost>
<VirtualHost 192.168.0.2:80>
ServerAdmin webmaster@baygroup.example.org
DocumentRoot /groups/baygroup/www
ServerName baygroup.example.com
ErrorLog /groups/baygroup/logs/error_log
TransferLog /groups/baygroup/logs/access_log
</VirtualHost>
It is recommended that you use an IP address instead of a hostname in the <VirtualHost> directive (see DNS caveats).
Specific IP addresses or ports have precedence over their wildcard equivalents, and any virtual host that matches has precedence over the servers base configuration.
Almost any configuration directive can be put in the VirtualHost directive, with the exception of directives that control process creation and a few other directives. To find out if a directive can be used in the VirtualHost directive, check the Context using the directive index.
SuexecUserGroup
may be used inside a
VirtualHost directive if the suEXEC
wrapper is used.
SECURITY: When specifying where to write log files, be aware of some security risks which are present if anyone other than the user that starts Apache has write access to the directory where they are written. See the security tips document for details.