// page information $page_type = "t"; $page_title = "Apache Core Features"; $page_keywords = "apache, web server, apache core features, directives, bindaddress, documentroot, listen, namevirtualhost, serveradmin, serveralias, servername, serverpath, serverroot, virtualhost"; $page_description = "Apache core features tutorial. Find more tutorials and scripts at TheScripts.com, a programming and software development resource, directory and community."; $page_articletitle = "Apache Core Features"; $page_next_url = ""; $page_next_anchor = ""; $page_prev_url = ""; $page_prev_anchor = ""; $page_author = ""; $page_byline = ""; // site header include ($_SERVER["DOCUMENT_ROOT"]."/header.php"); // begin html ?>
These are just a few parameters control the core Apache features.
BindAddress *A Unix® http server can either listen for connections to every IP address of the server machine, or just one IP address of the server machine. If the argument to this directive is *, then the server will listen for connections on every IP address. Otherwise, the server can listen to only a specific IP-address or a fully-qualified Internet domain-name.
For example:
BindAddress 192.168.15.48Only one BindAddress directive can be used.
This directive is deprecated and will be eliminated in Apache 2.0. Equivalent functionality and more control over the address and ports Apache listens to is available using the Listen directive.
BindAddress can be used as an alternative method for supporting virtual hosts using multiple independent servers, instead of using <VirtualHost> sections.
DocumentRoot /usr/local/apache/htdocsThis directive sets the directory from which httpd will serve files. Unless matched by a directive like Alias, the server appends the path from the requested URL to the document root to make the path to the document. Example:
DocumentRoot /usr/web
then an access to http://www.my.host.com/index.html refers to /usr/web/index.html.
There appears to be a bug in mod_dir which causes problems when the DocumentRoot has a trailing slash (i.e., "DocumentRoot /usr/web/") so please avoid that.
The Listen directive instructs Apache to listen to more than one IP address or port; by default it responds to requests on all IP interfaces, but only on the port given by the Port directive.
Note that you may still require a Port directive so that URLs that Apache generates that point to your server still work.
Multiple Listen directives may be used to specify a number of addresses and ports to listen to. The server will respond to requests from any of the listed addresses and ports.
For example, to make the server accept connections on both port 80 and port 8000, use:
Listen 80
Listen 8000
To make the server accept connections on two specified interfaces and port numbers, use
Listen 192.170.2.1:80
Listen 192.170.2.5:8000
The NameVirtualHost directive is a required directive if you want to configure name-based virtual hosts.
Although addr can be hostname it is recommended that you always use an IP address or wildcard, e.g.
NameVirtualHost 111.22.33.44
With the NameVirtualHost directive you specify the IP address on which the server will receive requests for the name-based virtual hosts. This will usually be the address to which your name-based virtual host names resolve. In cases where a firewall or other proxy receives the requests and forwards them on a different IP address to the server, you must specify the IP address of the physical interface on the machine which will be servicing the requests. If you have multiple name-based hosts on multiple addresses, repeat the directive for each address.
Note: the "main server" and any _default_ servers will never be served for a request to a NameVirtualHost IP Address (unless for some reason you specify NameVirtualHost but then don't define any VirtualHosts for that address).
Optionally you can specify a port number on which the name-based virtual hosts should be used, e.g.
NameVirtualHost 111.22.33.44:8080
In Apache 1.3.13 and greater you can specify a * for the addr. This creates a wildcard NameVirtualHost which will match connections to any address that isn't configured with a more specific NameVirtualHost directive or <VirtualHost> section. This is useful if you want only name-based virtual hosts and you don't want to hard-code the server's IP address into the configuration file.
The ServerAdmin sets the e-mail address that the server includes in any error messages it returns to the client.
It may be worth setting up a dedicated address for this, e.g.
ServerAdmin www-admin@foo.bar.com
as users do not always mention that they are talking about the server!
The ServerAlias directive sets the alternate names for a host, for use with name-based virtual hosts.
Example:
<VirtualHost *>
ServerName server.domain.com
ServerAlias server server2.domain.com server2
...
</VirtualHost>
The ServerName directive sets the hostname of the server; this is used when creating redirection URLs. If it is not specified, then the server attempts to deduce it from its own IP address; however this may not work reliably, or may not return the preferred hostname. For example:
ServerName www.example.com
would be used if the canonical (main) name of the actual machine were simple.example.com.
If you are using name-based virtual hosts, the ServerName inside a <VirtualHost> section specifies what hostname must appear in the request's Host: header to match this virtual host.
The ServerPath directive sets the legacy URL pathname for a host, for use with name-based virtual hosts.
ServerRoot /usr/local/apacheThe ServerRoot directive sets the directory in which the server lives. Typically it will contain the subdirectories conf/ and logs/. Relative paths for other configuration files are taken as relative to this directory.
<VirtualHost> and </VirtualHost> are used to enclose a group of directives which will apply only to a particular virtual host. Any directive which is allowed in a virtual host context may be used. When the server receives a request for a document on a particular virtual host, it uses the configuration directives enclosed in the <VirtualHost> section. Addr can be
<VirtualHost 10.1.2.3>
ServerAdmin webmaster@host.foo.com
DocumentRoot /www/docs/host.foo.com
ServerName host.foo.com
ErrorLog logs/host.foo.com-error_log
TransferLog logs/host.foo.com-access_log
</VirtualHost>
Each VirtualHost must correspond to a different IP address, different port number or a different host name for the server, in the former case the server machine must be configured to accept IP packets for multiple addresses. (If the machine does not have multiple network interfaces, then this can be accomplished with the ifconfig alias command (if your OS supports it), or with kernel patches like VIF (for SunOS(TM) 4.1.x)).
You can specify more than one IP address. This is useful if a machine responds to the same name on two different interfaces. For example, if you have a VirtualHost that is available to hosts on an internal (intranet) as well as external (internet) network. Example:
<VirtualHost 192.168.1.2 204.255.176.199>
DocumentRoot /www/docs/host.foo.com
ServerName host.foo.com
ServerAlias host
</VirtualHost>
The special name _default_ can be specified in which case this virtual host will match any IP address that is not explicitly listed in another virtual host. In the absence of any _default_ virtual host the "main" server config, consisting of all those definitions outside any VirtualHost section, is used when no match occurs.
You can specify a :port to change the port that is matched. If unspecified then it defaults to the same port as the most recent Port statement of the main server. You may also specify :* to match all ports on that address. (This is recommended when used with _default_.)