{"id":682,"date":"2005-06-17T12:50:40","date_gmt":"2005-06-17T16:50:40","guid":{"rendered":"http:\/\/wordpress.cephas.net\/?p=682"},"modified":"2005-06-17T12:50:40","modified_gmt":"2005-06-17T16:50:40","slug":"awstats-installation-notes","status":"publish","type":"post","link":"https:\/\/cephas.net\/blog\/2005\/06\/17\/awstats-installation-notes\/","title":{"rendered":"AWStats Installation Notes"},"content":{"rendered":"<p>I tried installing <a href=\"http:\/\/awstats.sourceforge.net\/\">AWStats<\/a> a couple months ago on my server, got frustrated after an hour or two of reading the documentation and trying to figure out permissions problems, gave up and then tried again about two weeks ago, this time with more patience.  Maybe after reading my notes (on RedHat Linux) someone else won&#8217;t have to exercise as much patience.  <\/p>\n<p>First step: download <a href=\"http:\/\/awstats.sourceforge.net\/\">AWStats<\/a>, unzip (I unpacked to \/usr\/local\/awstats\/) and then execute the following script to <a href=\"http:\/\/awstats.sourceforge.net\/docs\/awstats_setup.html\">start the setup process<\/a>:<br \/>\n<code><br \/>\nperl awstats_configure.pl<br \/>\n<\/code><br \/>\nAfter you complete that step, you&#8217;ll have a couple AWStats directives in your Apache configuration.  Since some of the sites I&#8217;ve written use servlet filters to do URL rewriting and because I wanted to minimize the number of AWStats entry points (AWStats was recently <a href=\"http:\/\/www.google.com\/search?q=awstats+exploit\">hacked<\/a>), I setup a virtual host in Apache as a reporting domain.  I then moved the AWStats directives inside this reporting virtual domain.<\/p>\n<p>Next, using the sample awstats.mysite.com.conf, you&#8217;ll need to create the a domain configuration file for every site that you want to report on and place each one in \/etc\/awstats\/ (read more about the domain configuration files <a href=\"http:\/\/awstats.sourceforge.net\/docs\/awstats_setup.html\">here<\/a>, scroll down to step #4 and #5). So I ended up with something like:<br \/>\n<code><br \/>\n# ls \/etc\/awstats<br \/>\nawstats.cephas.net.conf<br \/>\nawstats.blackberryblog.com.conf<br \/>\n...<br \/>\n<\/code><br \/>\nAfter you&#8217;ve got all your configuration files setup, you&#8217;ll want to run awstats against all your old log files (assuming that you&#8217;ve got old log files that you want to process). There&#8217;s no easy way of getting all your old log files processed, I had to modify the configuration file to point to the zipped up log file:<br \/>\n<code><br \/>\nLogFile=\"gzip -d &lt;\/usr\/hosts\/yoursite.com\/logs\/200205.zip | \"<br \/>\n<\/code><br \/>\nrun awstats:<br \/>\n<code><br \/>\nperl awstats.pl -config=yoursite.com -update<br \/>\n<\/code><br \/>\nand then modify the configuration file to point to the next month.  If I was better at shell scripting I&#8217;m sure I could have worked out some way of automating this, but I didn&#8217;t have that many log files laying around so it wasn&#8217;t a big deal.  After you&#8217;ve processed all your old log files, you&#8217;ll want to point AWStats to look at your current log files.  I configured my machine so that it always processes the log file based on yesterday&#8217;s date, so my configuration looked like this:<br \/>\n<code><br \/>\nLogFile=\"\/usr\/hosts\/yoursite.com\/logs\/%YYYY-24%MM-24.log\"<br \/>\n<\/code><br \/>\nand then I setup a cron job to execute AWStats every night by saving this snippet of code as a script and placing it in your \/etc\/cron.daily\/ folder (cron.daily runs based on the settings in \/etc\/crontab)<br \/>\n<code><br \/>\n#!\/bin\/bash<br \/>\ncd \/usr\/local\/awstats\/tools<br \/>\nperl awstats_updateall.pl now<br \/>\n<\/code><br \/>\nSo now you&#8217;ve got your configuration files, you&#8217;ve got a script that processes your logs automatically every night and you want to view the reports from a web browser.  So you point your web browser to:<br \/>\n<code><br \/>\nhttp:\/\/reporting.yoursite.com\/awstats\/awstats.pl?config=yoursite.com<br \/>\n<\/code><br \/>\nand if you&#8217;re like me at this point you&#8217;ll run into an error message that makes no sense at all:<br \/>\n<code><br \/>\n[Fri Jun 03 15:52:42 2005] [crit] [client xxx.xxx.xxx.xxx] (13)Permission denied: \/usr\/local\/awstats\/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable<br \/>\n<\/code><br \/>\nThe funny thing was that I didn&#8217;t have an htaccess file anywhere near the awstats configuration, this error message drove me batty.  After googling for an exceptionally long period of time, I updated both <code>\/var\/lib\/awstats\/<\/code> and <code>\/usr\/local\/awstats\/<\/code> so that the Apache user owned them.<br \/>\n<code><br \/>\nchown apache.apache \/var\/lib\/awstats<br \/>\nchown apache.apache \/usr\/local\/awstats<br \/>\n<\/code><\/p>\n<p>Finally, unless you want everyone to see your stats (and allow anyone to access the AWStats.pl script), you&#8217;ll want to lock down the cgi-bin directory so that only valid users can access your system. Create a .htaccess and a .htpasswd file in your \/usr\/local\/awstats\/wwwroot\/cgi-bin\/ directory (making to sure to set AllowOverride All in your  directive inside the VirtualHost in apache).  Configure your .htaccess to only allow access to valid-user:<br \/>\n<code><br \/>\nAuthName \"reporting\"<br \/>\nAuthType Basic<br \/>\nAuthUserFile \/usr\/local\/awstats\/wwwroot\/cgi-bin\/.htpasswd<br \/>\nRequire valid-user<br \/>\n<\/code><br \/>\nYou can create the .htpasswd file by running this command:<br \/>\n<code><br \/>\nhtpasswd -c $filename $username<br \/>\n<\/code><br \/>\nand then add users:<br \/>\n<code><br \/>\nhtpasswd $filename $username<br \/>\n<\/code><br \/>\nand make sure to modify your AWStats configuration file to allow access to __REMOTE_USER__ or the specific user that you want to grant access to that file.<\/p>\n<p>You should now have a working, secure and fully automated AWStats reporting system! Congratulations!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I tried installing AWStats a couple months ago on my server, got frustrated after an hour or two of reading the documentation and trying to figure out permissions problems, gave up and then tried again about two weeks ago, this time with more patience. Maybe after reading my notes (on RedHat Linux) someone else won&#8217;t &hellip; <a href=\"https:\/\/cephas.net\/blog\/2005\/06\/17\/awstats-installation-notes\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">AWStats Installation Notes<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,12],"tags":[],"_links":{"self":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/682"}],"collection":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/comments?post=682"}],"version-history":[{"count":0,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/682\/revisions"}],"wp:attachment":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/media?parent=682"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/categories?post=682"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/tags?post=682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}