没有不值得去解决的问题,也没有不值得去学习的技术!

Resolving Issues Encountered When Configuring AWStats on CentOS 6.2 64-bit

awstats.pl displays the source code instead of the statistics table.

作者:

在

I configured it based on two URLs:

http://www.centospub.com/make/awstats.html

http://www.centos.bz/2012/02/analyze-nginx-log-with-awstats/

I chose version awstats-7.2.tar.gz, which is the latest version. You need a VPN to download it.

I set this up on Alibaba Cloud CentOS 6.2 64-bit.

After the configuration was complete, I opened the URL http://*.*.*.*/awstats/awstats.pl?config=www.***.com,

A 403 error is shown, no permission to access.
A 403 error is shown, no permission to access.

Searching online, some said to set the permissions of /usr/local/awstats/ to 755 or even 777. I did that, but it still wouldn’t open. Later, I found a post suggesting the following:

<Directory “/usr/local/awstats/wwwroot”>
Options Includes ExecCGI FollowSymlinks
AllowOverride None
Order allow,deny
Allow from all
Require all granted (mainly added this line)
</Directory>

The 403 error finally disappeared, but when I opened the URL, it displayed the source code. I had to keep analyzing the issue:

awstats.pl displays the source code instead of the statistics table.
awstats.pl displays the source code instead of the statistics table.

There is a line in httpd.conf:

#LoadModule cgid_module modules/mod_cgid.so, which I changed to

LoadModule cgid_module modules/mod_cgid.so, but this caused Apache to fail to start. I finally checked the modules directory and found the reason was that mod_cgid.so did not exist. However, I noticed another file, mod_cgi.so, so I gave it a try by adding the line:

LoadModule cgi_module modules/mod_cgi.so. It finally opened, but the page was blank and prompted that it had not been updated. I was a bit frustrated.

I continued analyzing the issue. Finally, I cleared the contents of several log files, such as logs/access_log, because when executing

/root/awstats.sh, it reported an access_log format error and seemingly a permission warning as well.

Some time after clearing them, once the access_log and other log files had content again, I reran the command. Finally, http://*.*.*.*/awstats/awstats.pl?config=www.***.com displayed content. Well, the basic configuration is done, but I still need to set up username and password access to make it feel more secure.

Configuration in httpd.conf:

#
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses “/usr/local/awstats/wwwroot/classes/”
Alias /awstatscss “/usr/local/awstats/wwwroot/css/”
Alias /awstatsicons “/usr/local/awstats/wwwroot/icon/”
ScriptAlias /awstats/ “/usr/local/awstats/wwwroot/cgi-bin/”

#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory “/usr/local/awstats/wwwroot”>
Options Includes ExecCGI FollowSymlinks
AllowOverride None
Order allow,deny
Allow from all
AuthType Basic
AuthName “awstats access”
AuthUserFile /usr/local/awstats/htpasswd
Require valid-user
</Directory>

/usr/local/apache/bin/htpasswd -c /usr/local/awstats/htpasswd username (set this to your username for accessing awstats), then enter the password twice, and now it works. It took a day and a half, but the configuration is finally complete. Hehe!

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系