logo       awstats for virtual hosts: HOWTO You: 100.26.176.182         Thursday Dec 5, 2019   7:24AM PST

Follow these steps to install, configure, and run awstats on a server

  1. install the rpm with rpm -Uvh /root/rpms/awstats-3.2-1.noarch.rpm
  2. move README.TXT to the system documentation directory and remove unneeded man directory that remains:
    mv /opt/awstats/man/README.TXT /usr/share/doc/README.awstats.txt rmdir /opt/awstats/man
  3. edit www doc's to remove missing .js references:
    cd /var/www/ssl/wb/awstats ; vi '+/\.js' `grep -l '\.js' *`
  4. verify that the apache log is configured for combined format:
    egrep '^[^#].*CustomLog' /etc/httpd/conf/httpd.conf \
    	/etc/httpd/conf/include/*.conf
    	
  5. consolidate the awstats template dir:
    
           mv /opt/awstats/lang/ /opt/awstats/wwwroot/cgi-bin/
           mv /opt/awstats/wwwroot/ /opt
           rmdir /opt/awstats/
           mv /opt/wwwroot/ /opt/awstats
    
  6. on redhat, disable the default apache log rotation:
    
    	cp /etc/logrotate.d/apache /etc/logrotate.d/apache.old
    	echo "%s/^/#/
    	wq
    	" | ed /etc/logrotate.d/apache
    	cat !$
    

Note: The process has been automated. This document is obsolete.

Please see this document for information on the new automated installation tool.

The following steps must be performed for each virtual host

  1. install the template dir (copy) to someplace accessible by apache:
    
    	cp -a /opt/awstats/cgi-bin /var/www/cgi-bin/awstats
    	mkdir /var/www/awstats
    	cp -a /opt/awstats/icon /var/www/awstats
    
  2. copy the config template into /etc/awstats as /etc/awstats/awstats.conf or, for virtual hosts:
    /etc/awstats/awstats.virtualhostname.conf:
    
    	mv /etc/opt/awstats/ /etc
    	rmdir /etc/opt
    	cp /etc/awstats/awstats.model.conf /etc/awstats/awstats.some-domain.com.conf
    
  3. combine, if needed, any previously split apache log files in /var/log/httpd:
    
    service httpd stop
    cd /var/log/httpd
    cat access_log.4 access_log.3 access_log.2 access_log.1 access_log > access_log.new
    [ -d attic ] || mkdir attic
    for f in access_log.4 access_log.3 access_log.2 access_log.1 access_log ; do
    	mv $f attic
    done
    mv access_log.new access_log
    service httpd start
    
  4. copy the site logo image file into the icon/other directory:
    
    cp /var/www/html/img/logo.jpg /var/www/awstats/icon/other
    
  5. edit the config file created above:
    
    vi /etc/awstats/awstats.some-domain.com.conf
    
  6. create the data directory in /var/cache/awstats:
    
    mkdir /var/cache/awstats
    
  7. run awstats to initialize the data. will probably take a while. the following command line will capture the output and time the run:
    
    time /var/www/cgi-bin/awstats/awstats.pl -config=some-domain.com \
    	-update 2>&1 | tee /root/awstats.out
    
  8. configure the httpd.conf file for the site to create aliases for awstats and restart the server:
    
    Alias /awstats /var/www/awstats
    service httpd restart
    
  9. create a link on the website to point to the output in http://virtual.host.name/awstats/
  10. add a cron job for root to update the index the site hourly. additional hosts may simply add a line to the file:
    
    touch /etc/cron.hourly/awstats && chmod 754 /etc/cron.hourly/awstats
    cat < /etc/cron.hourly/awstats
    #!/bin/bash
    # update access statistics for the web site
    /var/www/cgi-bin/awstats/awstats.pl -config=some-domain.com -update
    exit 0
    EOM
    
  11. point your browser to the link, http://some-domain.com/cgi-bin/awstats.pl, and enjoy!

...dave


silly cat image Top of Page FEEDBACK      Comments, Corrections & Questions welcome