Jonathan's Contribution

Linux Configuration

Henry's Virtual WWW Serving


[Home] [Up][Prev][Next]

References

I'm using Apache as a web server.  Are you surprised.  I got all the information I needed off their web site. The stuff on Virtual hosts is especially useful.
 
BTW, do you know where Apache got its name? A patchy server!

What do we want to do?

We want to virtually serve two web sites www.cmex.org and www.novatek.co.nz, also off the novatek.co.nz domain, I want to serve websites for select users, for example jon.novatek.co.nz, vanessa.novatek.co.nz, steven.novatek.co.nz, and cara.novatek.co.nz.
 
Although it is not necessary to use different (aliased) ip addresses to configure this, we do so anyway.   Here, from the external world view, all communications with the novatek.co.nz domain arrives at Gateway, our firewall on 24.113.94.87; and the cmex.org domain arrives on 24.113.98.164.  Gateway's DNS configuration  makes this magic possible.  Gateway's Firewall and Port Forwarding configuration forwards all http traffic arriving on 24.113.94.87 and 24.113.98.164 to 192.168.0.200, and 192.168.0.202 respectively.  These 192.168.0.x addresses are ip aliased on Henry.
 
This organisation has the advantage of being able to separate out serving to separate boxes later without breaking too many things.  It is also consistant with the orgainization of the ftp setup.

Directory Structure

Henry keeps all its web sites rooted off /usr/local/www/. The web site subdirectories off this root are: (output of 'ls -l /usr/local/www')
 
---------------------------------------------------
drwxr-xr-x   2 cara     www          4096 Tue Feb 29 21:34:24 2000 cara/
drwxr-xr-x   3 cmex     www          4096 Sat Feb 19 10:56:01 2000 cmex/
drwxr-xr-x  10 jon      www          4096 Thu Feb 17 20:30:04 2000 jon/
drwxr-xr-x   3 novatek  www          4096 Wed Feb 16 22:09:26 2000 novatek/
drwxr-xr-x   2 steven   www          4096 Tue Feb 29 21:34:18 2000 steven/
drwxr-xr-x   2 vanessa  www          4096 Tue Feb 29 21:34:05 2000 vanessa/
----------------------------------------------------
 
Note that the directories belong to their respective logins, and all belong to the 'www' group. I added this group to /etc/group file with a gid of 60:
www:x:60:jon,novatek,cmex,vanessa,steven,cara,nobody
 
This structure is attractive to me, as logging in as the appropriate user, one can to the respective web site location to edit or ftp update. Note also, the use of the UserDir directive in the /etc/httpd/conf/httpd.conf, so that (for exaple) the use of www.novatek.co.nz/~jon, and jon.novatek.co.nz both work.
 

Configuration

Following is /etc/httpd/conf/http.conf, the configuration file for httpd, the apache server. To find out what is going on here, I would recommend looking up what every configuration item means in the Apache documentation.  I know this is tedious, but I cannot think of a better way to find out what is going on.
 
>>>>>>>>>>>>>>>>>>>>>/etc/httpd/conf/http.conf
### Section 1: Global Environment

ServerType standalone
ServerRoot "/etc/httpd"
LockFile /var/lock/httpd.lock
PidFile /var/run/httpd.pid
ScoreBoardFile /var/run/httpd.scoreboard
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MinSpareServers 5
MaxSpareServers 20
StartServers 8
MaxClients 150
MaxRequestsPerChild 100
#
# Dynamic Shared Object (DSO) Support
#
#LoadModule mmap_static_module modules/mod_mmap_static.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule env_module         modules/mod_env.so
LoadModule config_log_module  modules/mod_log_config.so
LoadModule agent_log_module   modules/mod_log_agent.so
LoadModule referer_log_module modules/mod_log_referer.so
#LoadModule mime_magic_module  modules/mod_mime_magic.so
LoadModule mime_module        modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule status_module      modules/mod_status.so
LoadModule info_module        modules/mod_info.so
LoadModule includes_module    modules/mod_include.so
LoadModule autoindex_module   modules/mod_autoindex.so
LoadModule dir_module         modules/mod_dir.so
LoadModule cgi_module         modules/mod_cgi.so
LoadModule asis_module        modules/mod_asis.so
LoadModule imap_module        modules/mod_imap.so
LoadModule action_module      modules/mod_actions.so
#LoadModule speling_module     modules/mod_speling.so
LoadModule userdir_module     modules/mod_userdir.so
LoadModule alias_module       modules/mod_alias.so
LoadModule rewrite_module     modules/mod_rewrite.so
LoadModule access_module      modules/mod_access.so
LoadModule auth_module        modules/mod_auth.so
LoadModule anon_auth_module   modules/mod_auth_anon.so
LoadModule db_auth_module     modules/mod_auth_db.so
LoadModule digest_module      modules/mod_digest.so
LoadModule proxy_module       modules/libproxy.so
#LoadModule cern_meta_module   modules/mod_cern_meta.so
LoadModule expires_module     modules/mod_expires.so
LoadModule headers_module     modules/mod_headers.so
LoadModule usertrack_module   modules/mod_usertrack.so
#LoadModule example_module     modules/mod_example.so
#LoadModule unique_id_module   modules/mod_unique_id.so
LoadModule setenvif_module    modules/mod_setenvif.so
#LoadModule bandwidth_module   modules/mod_bandwidth.so
#LoadModule put_module          modules/mod_put.so

# Extra Modules
#LoadModule php_module         modules/mod_php.so
LoadModule php3_module        modules/libphp3.so
LoadModule perl_module        modules/libperl.so

ClearModuleList
#AddModule mod_mmap_static.c
AddModule mod_vhost_alias.c
AddModule mod_env.c
AddModule mod_log_config.c
AddModule mod_log_agent.c
AddModule mod_log_referer.c
#AddModule mod_mime_magic.c
AddModule mod_mime.c
AddModule mod_negotiation.c
AddModule mod_status.c
AddModule mod_info.c
AddModule mod_include.c
AddModule mod_autoindex.c
AddModule mod_dir.c
AddModule mod_cgi.c
AddModule mod_asis.c
AddModule mod_imap.c
AddModule mod_actions.c
#AddModule mod_speling.c
AddModule mod_userdir.c
AddModule mod_alias.c
AddModule mod_rewrite.c
AddModule mod_access.c
AddModule mod_auth.c
AddModule mod_auth_anon.c
AddModule mod_auth_db.c
AddModule mod_digest.c
AddModule mod_proxy.c
#AddModule mod_cern_meta.c
AddModule mod_expires.c
AddModule mod_headers.c
AddModule mod_usertrack.c
#AddModule mod_example.c
#AddModule mod_unique_id.c
AddModule mod_so.c
AddModule mod_setenvif.c
#AddModule mod_bandwidth.c
#AddModule mod_put.c

# Extra Modules
#AddModule mod_php.c
AddModule mod_php3.c
AddModule mod_perl.c

#ExtendedStatus On

### Section 2: 'Main' server configuration
#
Port 80
User nobody
Group nobody
#ServerAdmin webkeeper@novatek.co.nz
#ServerName novatek.co.nz
#DocumentRoot "/usr/local/www/"
#
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
#
UserDir /usr/local/www

<Directory "/usr/local/www">
    Options MultiViews Includes FollowSymLinks ExecCGI
    AllowOverride All
    <Limit GET POST OPTIONS PROPFIND>
        Order allow,deny
        Allow from all
    </Limit>
    <Limit PUT DELETE PATCH PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
        Order deny,allow
        Deny from all
    </Limit>
</Directory>

<Directory "/home/ftp/">
    Options Includes Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

DirectoryIndex index.html index.htm index.shtml index.cgi index.php3
#
AccessFileName .htaccess
#
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
</Files>

#CacheNegotiatedDocs
#
UseCanonicalName On
#
TypesConfig /etc/mime.types
DefaultType text/plain
<IfModule mod_mime_magic.c>
    MIMEMagicFile share/magic
</IfModule>
#
HostnameLookups Off

ErrorLog /var/log/httpd/error_log
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%V %h %l %u %t \"%r\" %>s %b" vcommon
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog /var/log/httpd/access_log vcommon
#"
ServerSignature Off

# Alias fakename realname
Alias /icons/ "/home/httpd/icons/"

<Directory "/home/httpd/icons">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

#ScriptAlias /cgi-bin/ "/home/httpd/cgi-bin/"

#
# "/home/httpd/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/home/httpd/cgi-bin">
    AllowOverride None
    Options ExecCGI
    Order allow,deny
    Allow from all
</Directory>

#Redirect old-URI new-URL

IndexOptions FancyIndexing
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip

AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*

AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core

AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
DefaultIcon /icons/unknown.gif
#AddDescription "GZIP compressed document" .gz
#AddDescription "tar archive" .tar
#AddDescription "GZIP compressed tar archive" .tgz
#
ReadmeName README
HeaderName HEADER
#
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
# to do with the FancyIndexing customization directives above.
#
AddEncoding x-compress Z
AddEncoding x-gzip gz tgz
#
AddLanguage en .en
AddLanguage fr .fr
AddLanguage de .de
AddLanguage da .da
AddLanguage el .el
AddLanguage it .it
LanguagePriority en fr de
AddType application/x-httpd-php3 .php3
AddType application/x-httpd-php3-source .phps
#AddType application/x-httpd-php .phtml
AddType application/x-tar .tgz
#
AddHandler cgi-script .cgi
#
# To use server-parsed HTML files
#
AddType text/html .shtml
AddHandler server-parsed .shtml
#AddHandler send-as-is asis
AddHandler imap-file map
#AddHandler type-map var

#Action media/type /cgi-script/location
#Action handler-name /cgi-script/location
#MetaDir .web
#MetaSuffix .meta
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0

<IfModule mod_perl.c>
  Alias /perl/ /home/httpd/perl/
  <Location /perl>
    SetHandler perl-script
    PerlHandler Apache::Registry
    Options +ExecCGI
  </Location>
</IfModule>

Alias /doc/ /usr/doc/
<Location /doc>
  order deny,allow
  deny from all
  allow from localhost
  Options Indexes FollowSymLinks
</Location>

NameVirtualHost  192.168.0.200:80
NameVirtualHost  192.168.0.201:80
NameVirtualHost  192.168.0.202:80
NameVirtualHost  192.168.0.203:80

<VirtualHost 192.168.0.200:80>
    DocumentRoot  "/usr/local/www/novatek"
    ServerName    www.novatek.co.nz
    ServerAlias   novatek.co.nz
    ServerPath    "/usr/local/www/novatek"

    ServerAdmin   webkeeper@novatek.co.nz
    ScriptAlias   /cgi-bin/  /usr/local/www/novatek/cgi-bin
</VirtualHost>

<VirtualHost 192.168.0.201:80 192.168.0.200:80>
    DocumentRoot  "/usr/local/ftp/novatek"
    ServerName    ftp.novatek.co.nz
    ServerPath    "/usr/local/ftp/novatek"
    ServerAdmin   webkeeper@novatek.co.nz
    ScriptAlias   /cgi-bin/  /usr/local/www/novatek/cgi-bin
</VirtualHost>

<VirtualHost 192.168.0.202:80>
    DocumentRoot  "/usr/local/www/cmex"
    ServerName    www.cmex.org
    ServerAlias   cmex.org
    ServerPath    "/usr/local/www/cmex"
    ServerAdmin   webkeeper@cmex.org
    ScriptAlias   /cgi-bin/  /usr/local/www/cmex/cgi-bin
</VirtualHost>

<VirtualHost 192.168.0.203:80 192.168.0.202:80>
    DocumentRoot  "/usr/local/ftp/cmex"
    ServerName    ftp.cmex.org
    ServerPath    "/usr/local/ftp/cmex"
    ServerAdmin   webkeeper@cmex.co.nz
    ScriptAlias   /cgi-bin/  /usr/local/www/cmex/cgi-bin
</VirtualHost>

<VirtualHost 192.168.0.200:80>
    DocumentRoot  "/usr/local/www/jon"
    ServerName    jon.novatek.co.nz
    ServerPath    "/usr/local/www/jon"
    ServerAdmin   jon@novatek.co.nz
    ScriptAlias   /cgi-bin/  /usr/local/www/jon/cgi-bin
</VirtualHost>

<VirtualHost 192.168.0.200:80>
    DocumentRoot  "/usr/local/www/vanessa"
    ServerName    vanessa.novatek.co.nz
    ServerPath    "/usr/local/www/vanessa"
    ServerAdmin   vanessa@novatek.co.nz
    ScriptAlias   /cgi-bin/  /usr/local/www/vanessa/cgi-bin
</VirtualHost>

<VirtualHost 192.168.0.200:80>
    DocumentRoot  "/usr/local/www/steven"
    ServerName    steven.novatek.co.nz
    ServerPath    "/usr/local/www/steven"
    ServerAdmin   steven@novatek.co.nz
    ScriptAlias   /cgi-bin/  /usr/local/www/steven/cgi-bin
</VirtualHost>

<VirtualHost 192.168.0.200:80>
    DocumentRoot  "/usr/local/www/cara"
    ServerName    cara.novatek.co.nz
    ServerPath    "/usr/local/www/cara"
    ServerAdmin   cara@novatek.co.nz
    ScriptAlias   /cgi-bin/  /usr/local/www/cara/cgi-bin
</VirtualHost>
<<<<<<<<<<<<<<<<<<<<</etc/httpd/conf/http.conf
 
Now we can check out our web server configuration.  First we need to restart httpd with:
/etc/rc.d/init.d/httpd restart
 
Now put documents in the respective directorys and look at the web sites with your favourite browsers.  The configuration also permits http access to the virtually hosted ftp directories which are configured next.
 

[Home] [Up][Prev][Next]

Last modified: Tue Feb 8 22:00:00 PST 2000
Copyright © Jonathan Marks, 1999, 2000. All rights reserved.
http://jon.novatek.co.nz/linux/config/henry-www.html.