You don’t have permission to access /awstats/awstats.pl on this server.

I wrote a post on installing awstats on CentOS. That post actually teaches you to install awstats on CentOS 6, where you need to download the awstats package from sourceforge and install it and its dependent software manually. Today, I tried to install awstats on CentOS7 and the process became a little different.

First, you do not need to download and install the awstats rpm package any longer. You can use yum to install awstats and yum will install all dependent packages automatically for you. But you will be reminded by yum that awstats will be installed to non-standard location: /usr/share/ instead of the standard location /usr/local. I do not know the difference between /usr/share and /usr/local so I just typed “Y” to confirm the installation.

The remaining configuration process is the same as talked in that post. I created a conf file for my website domainhostseotool.com and edited some settings (LogFile, AllowToUpdateStatsFromBrowser ) in that conf file. You can get the detailed steps to create a conf file for your website in that post.

Then, the problem arose. When I visited the awstats webpage(http://domainhostseotoo.com/awstats/awstats.pl?config= domainhostseotoo.com), it displayed an error message in the browser:

I never encountered this problem before. If you search this error in google, you will see this post and this post. The method in the first post just does not work at all. The method introduced in the second post looks very complex and I did not even try it.

In fact, the problem is caused by  awstats.conf in /etc/httpd/conf.d/:

You can see if you visit http://domainhostseotoo.com/awstats/awstats.pl, you are actually visiting

However, that directory is restricted to access only from local by the <Directory> section. I’ve not found the document about “Require local” even on Apache’s office website(this page and this page). As I said, Apache is poorly documented. You can only guess what the mysterious instructions are used for. I guess “Require local” means only allowing access by visitors from local server(the server hosting the website and the awstats). Without this <Directory>, nobody can access resources outside the document directory of your website. Now what we can do is allowing more visitors to access the awstats script awstats.pl. So I changed “Require local” to “Require all granted”. Things got better. The awstats statistic page showed up in my browser. But when I clicked the “update” link to update the statistics, it said ” cannot write to /var/lib/awstats/xxxx.tmp”. I think the awstats.pl script needs to create files in that directory but the directory /var/lib/awstats/ is not writable by the apache user. The solution is simple: change the user/group of /var/lib/awstats to apache:apache.

 

Posted in tips of hosting