Home > HA & HPC, IT Architecture > resolved awstats 500 internal server error after installation on centos linux

resolved awstats 500 internal server error after installation on centos linux

May 21st, 2012


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/learn-linux/awstats-installation-steps-on-linux-centos/


support_me
Amounts