While the exact distribution probably doesn’t matter too much, some steps are pertinent only to Fedora (i.e. the Yum install). Honestly, follow the instructions in the awstats documentation closely and you should be fine. My point here is to point-out some of the finer details.
First step, install AWStats as root:
% sudo yum install awstats
Yum will install awstats into /usr/share/ (/usr/share/awstats)
Now run the configuration script
% cd /usr/share/awstats/tools/
% sudo perl awstats.pl
When it asks for the location of the server configuration file:
/etc/httpd/conf/httpd.conf (your apache conf file)
follow the remaining direction until you exit the configuration script. For the sake of this tutorial I’ll call the site “mysite.”
NOTE: Apache logs are typically in the common log file format. AWStats works to its fullest potential if you change the log file format to combined in your httpd file. If you choose to keep the common file format, you’ll have to make the appropriate changes in awstats.
Now configure the awstats config file you just created with the above script:
% sudo emacs /etc/awstats/awstats.mysite.conf
You’ll need to edit a few lines to get everything working:
(line 51) LogFile="/var/path/to/my/file_access.log"
(line 153) SiteDomain="subdomain.domain.ext"
#and any others you might be using
(line 168) HostAliases="subdomain.domain.ext 127.0.0.1 localhost"
#Optional, but improved security. Leaving this blank allows ALL, otherwise fill-in the IPs that you want to allow
(line 349) AllowAccessFromWebToFollowingIPAddresses="127.0.0.1"
One thing I was unable to get working correctly with HTTP authentication was:
(line 328) AllowAccessFromWebToAuthenticatedUsersOnly=1
(line 339) AllowAccessFromWebToFollowingAuthenticatedUsers = "__REMOTE_USER__"
now run the awstats.pl script:
% cd /usr/share/awstats/wwwroot/cgi-bin/
% sudo perl awstats.pl -update -config=mysite
If all goes well, you should see something along the lines of:
Found 0 dropped records
Found 0 corrupted records,
Found 150 old records,
Fount 50 new qualified records.
…at the end of the update script output.
So, to do this with multiple domains, just repeat the steps above, making sure to make the appropriate changes to each domain…
You should now be able to visit http://www.yoursite.ext/awstats/awstats.pl?config=mysite and you’ll see the fruits of your labor. I chose not to allow web users to do automatic updates. Rather, I have a cronjob set to run the awstats.pl -update script a once per day
(I don’t administer any high-traffic sites, so it’s not critical to have the most up-to-date records). You can see near the end of my Incremental backups with rsync post for more information on that, if you’re interested.
A word of caution: AWStats is often the target of worm attacks through XSS (cross-site scripting). One reason to use Yum to install/manage awstats is that you don’t have to do any of the work to keep it updated (make sure you enable automatic yum updates in your systems services config (menu: Desktop->System Settings -> Server Settings -> Services; check the “yum” option is checked and you click the “Start” button while it’s highlighted). Also make sure to limit who can see the awstats reports.