Apache Server Configuration

Introduction

For a general definition see: http://en.wikipedia.org/wiki/Apache_HTTP_Server, but more comprehensive information is available from the offical site at http://httpd.apache.org/.

The following guidance is might be useful in helping to configure Apache Web-server on a Linux server.

My Apache Server Configuration

After experimentation the following /etc/httpd/httpd.conf configuration file was arrived at, which allowed the set-up of a number of virtual servers on the same physical server.

===== httpd.conf fragment =====
#
# Based upon the NCSA server configuration files originally by Rob McCool.
# ...
#
### Section 1: Global Environment
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests it can handle or where it
# can find its configuration files.
...
# 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)
#

Listen 192.168.xxx.yyy:80
Listen 192.168.xxx.yyy:3aaaa
Listen 192.168.xxx.yyy:3bbbb
Listen 192.168.xxx.yyy:3cccc
...

### Section 2: 'Main' server configuration
...
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
# ...
ServerName server1.com

#
# UseCanonicalName: Determines how Apache constructs self-referencing 
# URLs and the SERVER_NAME and SERVER_PORT variables.
# When set "Off", Apache will use the Hostname and Port supplied
# by the client. When set "On", Apache will use the value of the
# ServerName directive.
#
UseCanonicalName on

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
# DocumentRoot "/var/www/html"
DocumentRoot "/home/www"

...
### Section 3: Virtual Hosts
#
...
#
# Use name-based virtual hosting.
#

NameVirtualHost 192.168.xxx.yyy:80
NameVirtualHost 192.168.xxx.yyy:3aaaa
NameVirtualHost 192.168.xxx.yyy:3bbbb
NameVirtualHost 192.168.xxx.yyy:3cccc
...

# Defaults for virtual hosts

# Logs

#
# Virtual hosts
#

# Virtual host Virtual Host 0

 	DocumentRoot /home/www
	DirectoryIndex index.html index.htm index.shtml 
	LogLevel warn


# Virtual host Virtual Host 1

 	DocumentRoot /home/www/MyPublicWebSite
 	ServerName servername1.com
 	ServerAlias if-one.com if.anotherone.com 
	DirectoryIndex index.html index.htm index.shtml 
	LogLevel warn


# Virtual host Virtual Host 2

 	DocumentRoot /home/www/MyTestWebSite 
 	ServerName servername2.com
 	ServerAlias MyTestWebServer
	DirectoryIndex index.html index.htm index.shtml 
	LogLevel warn


# Virtual host Virtual Host 3

 	DocumentRoot /home/www/usage
 	ServerName servername3.com
	DirectoryIndex index.html index.htm index.shtml 
	LogLevel warn


# Virtual host Virtual Host 4

 	DocumentRoot /var/www/mrtg
 	ServerName servername4.com
	DirectoryIndex index.html index.htm index.shtml 
	LogLevel warn

...
=====

There are numerous other entries to secure the web-server, etc. Details in the Apache documentation.

After installation http://localhost/manual should run up the Apache manual.

General Links

For general links to useful references when setting up Apache see: Apache resources on the Internet.

The following general links are also useful references when setting up Apache:


URLSummary/Description
http://httpd.apache.org/docs/1.3/misc/tutorials.html Apache tutorials
http://minitutorials.com/apache/apacheindex.shtml Apache 2 installation
http://www.mysql-apache-php.com/ Quick Linux Server Installation