po polsku


Red Hat® Linux 6 Unleashed










Chapter 9: Apache Server





Previous
ChapterNext
Chapter










Sections in this Chapter:








Server
Installation





CGI and
SSI






Runtime
Server Configuration Settings





Starting
and Stopping the Server






Virtual Hosting





Configuration
File Listings

















 

Previous
SectionNext
Section





Virtual Hosting



Address-Based
Virtual Hosts






Name-Based Virtual
Hosts





One
of the more popular services to provide with a Web server is to host a virtual
domain, also known as a virtual host. This is a complete Web site with its own
domain name, as if it was a standalone machine, but it's hosted on the same
machine as other Web sites. Apache implements this capability in a simple way
with directives in the http.conf configuration
file.There are two ways to host virtual hosts on an
Apache server. You can either have one IP address with multiple CNAMEs, or you
can have multiple IP addresses with one name per address. Apache has different
sets of directives to handle each of these
options.



Note - For information on setting
up your Linux machine with multiple IP addresses or giving your Linux
machine multiple CNAMEs, see on
DNS.



Address-Based Virtual Hosts
Once
you have configured your Linux machine with multiple IP addresses, setting up
Apache to serve them as different Web sites is quite simple. You need only put a
VirtualHost directive in your
httpd.conf file for each of the addresses that you
want to make an independent Web site:



<VirtualHost www.virtual.com>
ServerName www.virtual.com
DocumentRoot /home/virtual/public_html
TransferLog /home/virtual/logs/access_log
ErrorLog /home/virtual/logs/error_log
</VirtualHost>

It is recommended that you use the IP address, rather than the
hostname, in the VirtualHost
tag.You may specify any configuration directives
within the <VirtualHost> tags. For example,
you may want to set AllowOverrides directives
differently for virtual hosts than you do for your main server. Any directives
that are not specified default to the settings for the main
server.The directives that cannot be set in
VirtualHost sections are
ServerType,
StartServers,
MaxSpareServers,
MinSpareServers,
MaxRequestsPerChild,
BindAddress, Listen,
PidFile, TypesConfig,
ServerRoot, and
NameVirtualHost.



Name-Based Virtual Hosts
Name-based
virtual hosts allow you to run more than one host on the same IP address. You
need to add the additional names to your DNS as CNAMEs of the machine in
question. When a HTTP client (browser) requests a document from your server, it
sends with the request a variable indicating the server name from which it is
requesting the document. Based on this variable, the server determines from
which of the virtual hosts it should serve content.


Note -
Some older browsers are unable to see name-based virtual hosts because this is a
feature of HTTP 1.1, and those older browsers are strictly HTTP 1.0-compliant.
However, many other older browsers are partially HTTP 1.1-compliant, and this is
one of the parts of HTTP 1.1 that most browsers have supported for a
while.

Name-based virtual hosts require just one additional step more
than IP-address-based virtual hosts. You first need to indicate which IP address
has the multiple DNS names on it. This is done with the
NameVirtualHost directive.



NameVirtualHost 192.101.204.24

You then need to have a section for each name on that address,
setting the configuration for that name. As with IP-based virtual hosts, you
only need to set those configurations that need to be different for the host.
You must set the ServerName directive because that
is the only thing that distinguishes one host from
another:



<VirtualHost 192.101.204.24>
ServerName bugserver.databeam.com
ServerAlias bugserver
DocumentRoot /home/bugserver/htdocs
ScriptAlias /home/bugserver/cgi-bin
TransferLog /home/bugserver/logs/access_log
</VirtualHost>

<VirtualHost 192.101.204.24>
ServerName pts.databeam.com
ServerAlias pts
DocumentRoot /home/pts/htdocs
ScriptAlias /home/pts/cgi-bin
TransferLot /home/pts/logs/access_log
ErrorLog /home/pts/logs/error_log
</VirtualHost>

Tip -
If you are hosting Web sites on an intranet or internal network, there is often
a chance that users will use the shortened name of the machine rather than the
fully qualified domain name. For example, they might type
http://bugserver/index.html in their browser
location field, rather than
http://bugserver.databeam.com/index.html. In that
case, Apache will not recognize that those two addresses should go to the same
virtual host. You could get around this by setting up
VirtualHost directives for both
bugserver and
bugserver.databeam.com, but the easy way around this
is to use the ServerAlias directive, which lists all
valid aliases for the machine:

ServerAlias bugserver


Caution -
If you plan to run a large number of virtual hosts on your system, you should
consider sending all logged information to the standard Apache log files instead
of to individual files. The reason is that you may reach your system's file
descriptor limit (typically 64 per process) because you would be consuming one
file descriptor per log file. Symptoms of this problem include error messages
such as "unable to fork()," no information being written to the log
files, or poor response to http
requests.




Red Hat® Linux 6 Unleashed










Chapter 9: Apache Server





Previous
ChapterNext
Chapter










Sections in this Chapter:








Server
Installation





CGI and
SSI






Runtime
Server Configuration Settings





Starting
and Stopping the Server






Virtual Hosting





Configuration
File Listings

















 

Previous
SectionNext
Section





© Copyright Macmillan USA. All rights reserved.

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • pajaa1981.pev.pl