Installing awstats on Gentoo Linux

Here is what we are going to do.

  1. emerge awstats
  2. Install awstats using webapp-config
  3. Edit the apache configuration file /etc/apache2/httpd.conf
  4. Edit the awstats config file
  5. Update Statistics
  6. Update Cron

1. emerge awstats

Before emerging awstats, add “vhosts” to your use variables in your /etc/make.conf file. This will allow multiple copies of awstats to be installed, updated and deleted using the webapp-config tool.

emerge awstats

2. Install awstats using webapp-config

Since we are using the “vhost” use variable, emerging awstats does not fully install. We need to use the webapp-config tool to complete the installation.

webapp-config -I awstats 6.5 -h yourdomain.org -d awstats

This will install a copy of awstats in the directory /var/www/yourdomain.org/htdocs/awstats. The “6.5” is the version of awstats that you emerged in the previous section. It is important to note the output from this command as we will need this information for apache.

3. Edit the apache configuration file /etc/apache2/httpd.conf

We must now append the output from the webapp-config command to the /etc/apache2/httpd.conf file.

It’s also a good idea at this point to check if the CustomLog logs/access_log combined directive in httpd.conf is uncommented. This will ensure that awstats can read your apache logfile.

After these lines have been added, we must restart apache.

/etc/init.d/apache2 restart

4. Edit the awstats config file

Firstly, make a copy of the example file for yourdomain.org.

cp /etc/awstats/awstats.model.conf
/etc/awstats/awstats.yourdomain.org.conf

Next we edit this file. The main change we need to make is to the SiteDomain and HostAliases value pairs.

SiteDomain=yourdomain.org
HostAliases="www.yourdomain.org

awstats should now be configured.

5. Update Statistics

We must now run awstats on our log files.

/usr/share/webapps/awstats/6.5/hostroot/cgi-bin/awstats.pl -config=yourdomain.org -update

Update Cron

It would be useful if we didn’t need to run this command manually every time we want to update our stats. One solution is to edit your config file allowing updates to be performed from the webapage. However, you need to mess around with permissions to get this working. My preferred solution is to add the update script to my crontab. Typing

crontab -e

brings up your crontab using your default editor (as defined in /etc/rc.conf). You can now add the line

37 0 * * * /usr/share/webapps/awstats/6.5/hostroot/cgi-bin/awstats.pl -config=yourdomain.org -update >/dev/null 2>&1

This means this command will be run nightly, by cron at 12:37am. The extra code on the end ensures that cron doesn’tt automatically email the user every night when this job runs.

Congratulations, you should now be able to navigate to http://yourdomain.org/awstats/.

Useful Links

5 Responses to “Installing awstats on Gentoo Linux”

  1. hola Says:

    exactly what lines are we adding to httpd.conf on part 3? everything else seems easily followable (

  2. Administrator Says:

    Hi Hola,

    The lines which the webapp-config outputs in part 2 are added to the http.conf. In my case this was …

    Alias /awstats/classes “/usr/share/webapps/awstats/6.5/htdocs/classes/”
    Alias /awstats/css “/usr/share/webapps/awstats/6.5/htdocs/css/”
    Alias /awstats/icons “/usr/share/webapps/awstats/6.5/htdocs/icon/”
    ScriptAlias /awstats/ “/usr/share/webapps/awstats/6.5/hostroot/cgi-bin/”
    ScriptAlias /awstats “/usr/share/webapps/awstats/6.5/hostroot/cgi-bin/awstats.pl”
    ScriptAlias /awstats.pl “/usr/share/webapps/awstats/6.5/hostroot/cgi-bin/awstats.pl”


    Options None
    AllowOverride None

    Order allow,deny
    Allow from all


    Options ExecCGI
    AllowOverride None

    Order allow,deny
    Allow from all

    Hope this helps.

  3. hola Says:

    thank you for taking the time to reply. if i had paid attention after running webapp-config i should have noticed this!

    on another note, the default logging by apache2 didn’t work for when i tried updating awstats the first time, so i had to edit httpd.conf to have a combined log format. anyone else having problems with this shouldn’t have too much trouble fixing it, just uncomment two lines.

    my last reply got cut off, but i was thanking you for putting this all up here. i go so long between gentoo installs that i forget how to do some of the little things that can be such a nightmare sometimes!

    thanks again!

  4. Master Says:

    I followed this, but when I type http://www.mydomain.org/awstats is get 404. I cannot see where in Apache ServerName http://www.mydomain.org is set.

  5. Administrator Says:

    Hi Master,

    Does http://www.mydomain.org work? If not, then it sounds like you need to configure apache correctly. If http://www.mydomain.org does work then it could be a number of problems.

    1. Did you append the ouput of webapp-config to the httpd.conf file?
    2. Did you restart apache?
    3. Did you install awstats in the correct sub directory?

    To answer your question, ServerName is set in the /etc/conf/apache2/httpd.conf file. To see what yours is set to try

    cat /etc/apache/httpd.conf | grep -i servername

    However, if you have virtual hosts set up this may not be set to mydomain.org. You may also want to look at the /etc/apache2/vhosts.d/ directory.

    Good Luck.

Leave a Reply