Archive

Posts Tagged ‘awstats’

awstats installation and configuration guide on linux centos

May 21st, 2012 1 comment

Here's a howto/guide about awstats installation and configuration on linux:

yum -y install awstats

here's main things installed:

/var/www/awstats
/etc/awstats
/etc/cron.hourly/00awstats
/etc/httpd/conf.d/awstats.conf
/usr/bin/awstats_buildstaticpages.pl
/usr/bin/awstats_exportlib.pl
/usr/bin/awstats_updateall.pl
/usr/bin/logresolvemerge.pl
/usr/bin/maillogconvert.pl
/usr/bin/urlaliasbuilder.pl

mv /etc/awstats/awstats.localhost.localdomain.conf /etc/awstats/awstats.mysite.conf
vi /etc/awstats/awstats.mysite.conf

LogFile="/usr/bin/logresolvemerge.pl /var/log/httpd/*-access.log|"

#there's a way to add gzipped log file for analyzing
#LogFile="gzip -d </var/log/apache/access.log.gz|"
LogType=W #W is for analyzing web log files
LogFormat=1 #or use a custom log format if you don't use the combined log format
SiteDomain="www.yoursite.com"
AllowToUpdateStatsFromBrowser=1

cd /var/www/awstats/

chmod -R 755 /var/log/httpd #If you do not add x permission to these log files, you'll encounter error message below when you click "Update now" in browser:

awstats Couldn't open server log file xxxx: Permission denied

perl ./awstats.pl -config=mysite -update #or update from browser. or through logrotate(http://awstats.sourceforge.net/docs/awstats_faq.html#ROTATE) or through crontab(http://awstats.sourceforge.net/docs/awstats_faq.html#CRONTAB)
perl ./awstats.pl -config=mysite -output -staticlinks > awstats.mysite.html
Now visit http://www.yoursite.com/awstats-html/awstats.mysite.html#or through http://www.yoursite.com/awstats/awstats.pl?config=mysite(like http://www.yoursite.com/awstats/awstats.pl?month=MM&year=YYYY&output=unknownos). Reports are generated in real time from the statistics data base. If this is slow, or putting too much load on your server, consider generating static reports instead.
Here's the httpd configuration file for awstats:

[root@doxer awstats]# cat /etc/httpd/conf.d/awstats.conf
Alias /awstats/icon/ /var/www/awstats/icon/
Alias /awstats-html/ /var/www/awstats/
ScriptAlias /awstats/ /var/www/awstats/
<Directory /var/www/awstats/>
AllowOverride All
DirectoryIndex awstats.pl
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
#Alias /css/ /var/www/awstats/css/
#Alias /js/ /var/www/awstats/js/

NB:

1.If you encounter 500 internal server error, this article may be useful for you to troubleshoot http://www.doxer.org/resolved-awstats-500-internal-server-error-after-installation-on-centos-linux/

2.For more info, you can refer to official site here http://awstats.sourceforge.net/docs/index.html

resolved awstats 500 internal server error after installation on centos linux

May 21st, 2012 No comments

After installation of awstats on centos according to official installation guide, the dynamically view from browser was rendering ok, i.e. http://www.mysite.com/awstats/awstats.pl?config=mysite was ok and I can see statistics with no problem. However, when I tried view the static html page generated by perl ./awstats.pl -config=mysite -output -staticlinks > awstats.mysite.html, there was 500 internal server error when visiting this page: http://www.mysite.com/awstats/awstats.mysite.html.

This is quite weird because usually the ones that complain about 500 internal server error are usually dynamically generated pages such as php pages or perl cgi script pages. But this problem was that only static html page gave 500 internal server error, and the dynamically generated pages were ok to render. I tried moving the html file to some other virtualhost and it's ok to render without the horrible 500 internal server error: statistics looked good and all icons were ok.

The configuration of awstats in httpd conf file was like this:

[root@doxer awstats]# cat /etc/httpd/conf.d/awstats.conf
Alias /awstats/icon/ /var/www/awstats/icon/
ScriptAlias /awstats/ /var/www/awstats/
<Directory /var/www/awstats/>
AllowOverride All
DirectoryIndex awstats.pl
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
#Alias /css/ /var/www/awstats/css/
#Alias /js/ /var/www/awstats/js/

Pay attention to line with red color. It took me a whole forenoon before I found the root cause(there was no useful error log for this awstats 500 internal server error). As detailed in httpd documents:

The ScriptAlias directive has the same behavior as the Alias directive, except that in addition it marks the target directory as containing CGI scripts that will be processed by mod_cgi's cgi-script handler.

This is quite clear that files under directory followed by ScriptAlias directive will be treated as CGI scripts. As the static html file was placed under the directory which should only contains CGI scripts, so 500 internal server error threw when visiting that static html file under it.

To fix this awstats 500 internal server error, change the configuration file as the following:

[root@doxer awstats]# cat /etc/httpd/conf.d/awstats.conf
Alias /awstats/icon/ /var/www/awstats/icon/
Alias /awstats-html/ /var/www/awstats/
ScriptAlias /awstats/ /var/www/awstats/
<Directory /var/www/awstats/>
AllowOverride All
DirectoryIndex awstats.pl
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
#Alias /css/ /var/www/awstats/css/
#Alias /js/ /var/www/awstats/js/

After this, you should now be able to see the awstats static html file with no problem.(use http://www.mysite.com/awstats-html/awstats.mysite.html instead of http://www.mysite.com/awstats/awstats.mysite.html)

NB:

Here's an article about awstats installation on linux howto:  http://www.doxer.org/awstats-installation-steps-on-linux-centos/