Web server statistics: JAWStats

Table of Contents

Setup AWStats
Setup JAWStats

Setup AWStats

by ross at 07:23:20 on October 28, 2011

Install

# cd /usr/ports/net/p5-Geo-IP
# make install clean
# cd /usr/local/share/GeoIP
# fetch http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
# gunzip GeoLiteCity.dat.gz
# cd /usr/ports/www/awstats
# make installl clean

Configure

As we will install JAWStats we won't need AWStats web interface so no need to configure it.

If, for example, your site configured as virtual host:

<VirtualHost *:80>
        ServerName example.com
        ServerAdmin [email protected]
        DocumentRoot "/home/www/example.com"
        ErrorLog "/var/log/httpd-example.com-error.log"
        CustomLog "/var/log/httpd-example.com-access.log" combined
</VirtualHost>

And your log rotation setup is the following:

/var/log/httpd-*.log    www:wheel       644  7     *    @T00  BJG /var/run/httpd.pid 30

I.e. logs are rotated at midnight. Let's configure AWStats.

# cd /usr/local/www/awstats/tools
# perl awstats_configure.pl
  • Enter none to skip web server setup
  • Enter y to create new config file
  • Enter web site name: example.com
  • Set /usr/local/etc/awstats as config path

Edit awstats_updateall.pl in the same directory, find $DIRCONFIG and change:

my $DIRCONFIG = "/usr/local/etc/awstats";

Edit /usr/local/etc/awstats/awstats.example.com.conf:

--- /usr/local/www/awstats/cgi-bin/awstats.model.conf   2011-08-07 19:31:15.000000000 +0300
+++ /usr/local/etc/awstats/awstats.example.com.conf  2011-08-08 07:22:12.000000000 +0300
@@ -48,7 +48,7 @@
 # If there are several log files from load balancing servers :
 # Example: "/pathtotools/logresolvemerge.pl *.log |"
 #
-LogFile="/var/log/httpd/mylog.log"
+LogFile="bzcat /var/log/httpd-example.com-access.log.0.bz2 |"
 
 
 # Enter the log file type you want to analyze.
@@ -150,7 +150,7 @@
 # Example: "ftp.domain.com"
 # Example: "domain.com"
 #
-SiteDomain=""
+SiteDomain="example.com"
 
 
 # Enter here all other possible domain names, addresses or virtual host
@@ -165,7 +165,7 @@
 # Note: You can also use @/mypath/myfile if list of aliases are in a file.
 # Example: "www.myserver.com localhost 127.0.0.1 REGEX[mydomain\.(net|org)$]"
 #
-HostAliases="localhost 127.0.0.1 REGEX[myserver\.com$]"
+HostAliases="localhost 127.0.0.1 REGEX[example\.com$]"
 
 
 # If you want to have hosts reported by name instead of ip address, AWStats
@@ -200,7 +200,7 @@
 # Example: "C:/awstats_data_dir"
 # Default: "."          (means same directory as awstats.pl)
 #
-DirData="/var/lib/awstats"
+DirData="/home/awstats"
 
 
 # Relative or absolute web URL of your awstats cgi-bin directory.
@@ -463,7 +463,8 @@
 # Example: "localhost REGEX[^.*\.localdomain$]"
 # Default: ""
 #
-SkipHosts=""
 # IP address of your web server and possibly other IPs
+SkipHosts="127.0.0.1 178.137.14.143"
 
 
 # Do not include access from clients with a user agent that match following
@@ -476,7 +476,7 @@
 # Example: "konqueror REGEX[ua_test_v\d\.\d]"
 # Default: ""
 #
-SkipUserAgents=""
+SkipUserAgents="Zend_Http_Client"
 
 
 # Use SkipFiles to ignore access to URLs that match one of following entries.
@@ -494,7 +494,8 @@
 # Example: "/badpage.php /page.php?param=x REGEX[^\/excludedirectory]"
 # Default: ""
 #
-SkipFiles=""
+# If you run Pimcore:
+SkipFiles="REGEX[^\/admin] REGEX[^\/plugin]"
 
 
 # Use SkipReferrersBlackList if you want to exclude records coming from a SPAM
@@ -902,7 +903,7 @@
 #  First available language accepted by browser=auto
 # Default: "auto"
 #
-Lang="auto"
+Lang="en"
 
 
 # Set the location of language files.
@@ -1419,6 +1420,7 @@
 # Replace spaces in the path of geoip data file with string "%20".
 #
 #LoadPlugin="geoip GEOIP_STANDARD /pathto/GeoIP.dat"
+LoadPlugin="geoip GEOIP_STANDARD /usr/local/share/GeoIP/GeoIP.dat"
 
 # PLUGIN: GeoIP_City_Maxmind
 # REQUIRED MODULES: Geo::IP or Geo::IP::PurePerl (from Maxmind)
@@ -1428,6 +1430,7 @@
 # Replace spaces in the path of geoip data file with string "%20".
 #
 #LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /pathto/GeoIPCity.dat"
+LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /usr/local/share/GeoIP/GeoLiteCity.dat"
 
 # PLUGIN: GeoIP_ASN_Maxmind
 # REQUIRED MODULES: Geo::IP or Geo::IP::PurePerl (from Maxmind)

As you can see LogFile is set to last rotated file. Run AWStats after midnight and you won't miss any visits. Add to root's crontab:

#minute hour    mday    month   wday    command
0       1       *       *       *       perl /usr/local/www/awstats/tools/awstats_updateall.pl now > /dev/null 2>&1

Don't forget to create data directory (/home/awstats).

Setup other virtual hosts just like that.

Comments