apache virtual hosts, user accounts with public html, webalizer reports
December 21st, 2008Set up httpd.conf with a virtual host for each url.
/etc/httpd/conf/httpd.conf
Listen 80
NameVirtualHost *:80
<VirtualHost *:80>
ServerSignature off
DirectoryIndex index.php index.html index.htm index.shtml index.pl
LogLevel debug
HostNameLookups off
</VirtualHost>
<VirtualHost *:80>
ServerName www.labellepageantwear.com
ServerAlias *labellepageantwear.com
DocumentRoot /home/labelle/public_html/
DirectoryIndex index.php index.html index.htm index.shtml index.pl
ErrorLog /var/log/httpd/labellepageantwear.com-error_log
CustomLog /var/log/httpd/labellepageantwear.com-access_log common
</VirtualHost>
<VirtualHost *:80>
ServerName www.missidahofalls.org
ServerAlias *missidahofalls.org
DocumentRoot /home/missif/public_html/
DirectoryIndex index.php index.html index.htm index.shtml index.pl
ErrorLog /var/log/httpd/missidahofalls.org-error_log
CustomLog /var/log/httpd/missidahofalls.org-access_log common
</VirtualHost>
<VirtualHost *:80>
ServerName www.missrexburg.org
ServerAlias *missrexburg.org
DocumentRoot /home/missrex/public_html/
DirectoryIndex index.php index.html index.htm index.shtml index.pl
ErrorLog /var/log/httpd/missrexburg.org-error_log
CustomLog /var/log/httpd/missrexburg.org-access_log common
</VirtualHost>
# allow each user to have a public html folder
<Directory “/home/*/public_html”>
Options Indexes Includes FollowSymLinks
Order Deny,Allow
AllowOverride authConfig
Allow from all
Order allow,deny
</Directory>
# prevent index of labelle catalog
<Directory “/home/labelle/public_html/catalog”>
Options -Indexes
</Directory>
Restart apache for the configuration to take effect.
service httpd restart
create each access and error log file:
touch /var/log/httpd/missif.org-error_log
touch /var/log/httpd/missif.org-access_log
touch /var/log/httpd/missrexburg.org-error_log
touch /var/log/httpd/missrexburg.org-access_log
Setup webalizer for each virtual host.
mkdir /etc/webalizer
mv /etc/webalizer.conf /etc/webalizer/.
copy webalizer.conf to a unique file for each virtual host
cp /etc/webalizer/webalizer.conf /etc/webalizer/labellepageantwear.com.conf
cp /etc/webalizer/webalizer.conf /etc/webalizer/missidahofalls.org.conf
cp /etc/webalizer/webalizer.conf /etc/webalizer/missrexburg.org.conf
edit /etc/webalizer/webalizer.conf
leave LogFile /var/log/httpd/access_log
change OutputDir /var/www/usage/default
I changed the hostname to the static IP on the local LAN HostName 192.168.1.50
Every thing else stayed the same.
Now, update the following items for each virtual host in their conf file
LogFile /var/log/httpd/missrexburg.org-access_log
OutputDir /var/www/usage/missrex
HistoryName /var/lib/webalizer/missrex.webalizer.hist
IncrementalName /var/lib/webalizer/missrex.webalizer.current
HostName www.missrexburg.org
Setup a folder for each webalizer report:
mkdir /var/www/usage/default
mkdir /var/www/usage/labelle
mkdir /var/www/usage/missif
mkdir /var/www/usage/missrex
in each folder place a copy of msfree.png and webalizer.png
cp /var/www/usage/msfree.png /var/www/usage/labelle/.
cp /var/www/usage/webalizer.png /var/www/usage/labelle/.
I also created a folder for all the old data
mkdir /var/www/usage/old_data
and moved all the old webalizer stuff into the old_data folder
mv /var/www/usage/* /var/www/usage/old_data/.
Setup the webalizer cron script to run each conf file:
/etc/cron.daily/00webalizer
#! /bin/bash
# update access statistics for the web site
#if [ -s /var/log/httpd/access_log ] ; then
# /usr/bin/webalizer
#fi
for i in /etc/webalizer/*.conf; do /usr/bin/webalizer -c $i; done
exit 0
I also set up /etc/httpd/conf.d/webalizer.conf to allow an index of the usage folder and only allow browsers on the LAN to see webalizer reports.
#
# This configuration file maps the webalizer log analysis
# results (generated daily) into the URL space. By default
# these results are only accessible from the local host.
#
Alias /usage /var/www/usage
<Location /usage>
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 192.168.1. # local subnet
Allow from ::1
Options +Indexes
</Location>
Restart apache for the configuration to take effect.
service httpd restart
Last of all, make sure each domain’s dns entry is pointing to your ip address. I found out the hard way that this doesn’t work if you are using forwarding….
Try ping or nslookup on one of your domains to make sure the ip address is correct.

























