Httpd Virtual Host Configuration: Difference between revisions
Line 7: | Line 7: | ||
Virtual hosts can be declared using the <tt><VirtualHost></tt> configuration element. <tt><VirtualHost></tt> encloses a group of directives that apply to only a particular virtual host. | Virtual hosts can be declared using the <tt><VirtualHost></tt> configuration element. <tt><VirtualHost></tt> encloses a group of directives that apply to only a particular virtual host. | ||
<pre> | |||
<VirtualHost <ip>:<port>> | |||
</VirtualHost> | |||
</pre> | |||
=Name-Based Virtual Host Configuration= | =Name-Based Virtual Host Configuration= |
Revision as of 04:57, 6 January 2016
Internal
Overview
Virtual hosts can be declared using the <VirtualHost> configuration element. <VirtualHost> encloses a group of directives that apply to only a particular virtual host.
<VirtualHost <ip>:<port>> </VirtualHost>
Name-Based Virtual Host Configuration
For each virtual host you want to serve, create a <VirtualHost> section.
The <VirtualHost> section must contain at minimum a ServerName directive to designate what host to serve and a DocumentRoot directive to indicate the file system directory that contains the content to server.
Configuration Inheritance
All directives present in the httpd configuration file above the <VirtualHost> section set up the values used by the "main" server, which responds to any requests that are not handled by a <VirtualHost> definition. These values also provide defaults for any <VirtualHost> containers that defined later in the file.
If any of these directives appear inside a <VirtualHost> container, their values override the "main" defaults.
Overridable directives:
Example
# # ... the "main" section # IncludeOptional conf.d/*.conf <VirtualHost> </VirtualHost> <VirtualHost> </VirtualHost>