# Mini HowTo AWStats

## enobis

Mini HowTo - AWStats

Motivation

After searching the Web and here in the Gentoo forums, it appears that many people have had issues getting AWStats to work from the ebuild (I was no exception).  After having past mixed success with webapp-config, I knew I did not want to go down that path.  This howto illustrates which configuration files need to be modified to get you operational without needing to run webapp-config or any of the config tools that come with awstats.  Hopefully this "mini" howto will provide some assistance to those in need.

Software

This howto was written using the current ebuild for awstats 6.1 and apache2

```
emerge awstats
```

My installs were for servers with virtual hosting, so if you plan on using AWStats with virtual hosts then add the USE flag:

```
USE="vhosts" emerge awstats
```

AWStats is installed into the following directory: /usr/share/webapps/awstats/6.1

Apache Configuration

Step 1:

Start by copying the file postinst-en.txt to the apache config directory

```
cp /usr/share/webapps/awstats/6.1/postinst-en.txt /etc/apache2/conf/awstats.conf
```

Step 2:

Edit the newly copied file /etc/apache2/conf/awstats.conf by adding the following section:

```
<Directory "/usr/share/webapps/awstats/6.1/hostroot/cgi-bin/">

    Options ExecCGI

    SetHandler cgi-script

    Order allow,deny

    Allow from all

</Directory>
```

If you would also like to have awstats password protected then you can also add the following section:

```
<Directory "/usr/share/webapps/awstats/6.1/hostroot">

    Options None

    AllowOverride None

    Order allow,deny

    Allow from all

    AuthType Basic

    AuthName AWStats

    AuthUserFile /etc/awstats/users.pwd

    require valid-user

</Directory>
```

note the location of the password file (/etc/awstats/users.pwd), we will make this shortly.

Step 3:

Edit the Apache configuration file to include the newly created awstats.conf by adding the following to the /etc/apache2/conf/apache2.conf file:

```
Include conf/awstats.conf
```

If you are looking for a place to add the line, if you go just after the modules section (about a third down) there is a section for Global Configuration.

Step 4 (optional):

If you added the section for password protecting the awstats then you will need to create the /etc/awstats/users.pwd file using the htpasswd2 program by executing the following:

```
htpasswd2 -c /etc/awstats/users.pwd <username>
```

You will need to replace <username> with an actual username - the program will then prompt you for a password.  You can also add additional users to the file by running htpasswd2 again, but without the create flag:

```
htpasswd2 /etc/awstats/users.pwd <anotheruser>
```

Note: For compatability, as of apache2, htpasswd was renamed to htpasswd2.

AWStats Modifications and Configuration

Step 1:

The permissions for some of the awstats directories and files need to be modified as such:

```
chmod -R 755 /usr/share/webapps/awstats/6.1/hostroot/cgi-bin/lang

chmod -R 755 /usr/share/webapps/awstats/6.1/hostroot/cgi-bin/lib

chmod -R 755 /usr/share/webapps/awstats/6.1/hostroot/cgi-bin/plugins

chmod -R 755 /usr/share/webapps/awstats/6.1/htdocs/icon
```

Step 2:

Modify the awstats model config file /etc/awstats/awstats.model.conf, the setting for the directive DirIcons is incorrect.  Change the directive to the following:

```
DirIcons="/awstatsicons"
```

Step 3:

Copy the awstats model config file for your website, or if virtual hosting, for each website hosted.  So for www.mydomain.com you would do the following:

```
cp /etc/awstats/awstats.model.conf /etc/awstats/awstats.www.mydomain.com.conf
```

Note: the awstats instructions are a bit confusing, they say use your virtual domain.  However, you really need to use the FQDN for your web server (or virtual host), because when you call the awstats script from the browser, it will use the FQDN for finding the config file and stat files.

Step 4:

You need to create a directory for storing the awstats statistical files.   You may want to make the directory /var/www/localhost/awstats or if you are virtual hosting, then perhaps /var/www/mydomain.com/awstats.  You will need to have an awstats directory for every site you are hosting if you have a virtual hosting setup.

Step 5:

Modify your awstats config file /etc/awstats/awstats.www.mydomain.com.conf so that the required directives are set accordingly.  The following are the ones you will need to change:

```
LogFile="/path/to/your/sites/apache/access_log"

SiteDomain="mydomain.com"

HostAliases="www.mydomain.com localhost 127.0.0.1 REGEX[mydomain\.com$]"

```

Note: if virtual hosting, then only put the FQDNs (and/or REGEX) used to connect to the site and omit the localhost 127.0.0.1 from the HostAliases directive.

Next, modify the DirData directive to reflect the directory you made in Step 4.

```

DirData="/var/www/localhost/awstats"

```

If you changed the LogFormat in the apache log from the default combined then you will need to also modify the LogFormat directive in the awstats config file accordingly.

Build Statistic Files and View

You are now ready to build your statistic files for the first time, execute the following command:

```
/usr/share/webapps/awstats/6.1/hostroot/cgi-bin/awstats.pl -config=www.mydomain.com -update
```

Restart Apache so that your configuration changes will be take affect:

```
/etc/init.d/apache2 restart
```

Then view your newly created stats by entering the following url in your Web browser:

```
http://www.mydomain.com/awstats/awstats.pl
```

If you password protected awstats, then you will be prompted to enter the username and password you added with htpasswd2.

Further Reading

This mini howto was simply created to get you going.  For more information regarding awstats, refer to the online documentation at:

http://awstats.sourceforge.net/docs/index.html

I currently keep my log files for each virtual host seperate, however, if you want to consolidate all virtual hosting records into a single access_log file, the following site has great information for making awstats parse the file correctly for each virtual host:

http://www.dotvoid.com/view.php?id=29

Also on that site are some ideas and scripts for automating (or at least simplifying) the creation or addition of new virtual hosts with awstats.

Good luck, and I hope someone finds this useful.

----------

## g_os

Hello,

Thanks, work great for me with VHOST.

Note that I shoudl switch to log type 4 for ssl

G_os

----------

## Caustiq

Great guide. I was able to get awstats running in less than 5 min with your help.

Thanks.

----------

## enobis

Glad to hear it helped...

----------

## buchan

Excellent howto. 

I was looking around for something like this about a month ago and came up with nothing. Thanks for taking the time to write it.

----------

## yassen

enobis: thanks for the excellent howto. Saved me much time and effort!

As I have a lot of domains to tune, I came up whith a script for generating the awstats.$mydomain.conf files instead of copying the template and editing by hand. Here it is in case anyone would need a speed up:

```
# YD, 2005-01-20

# creating all awstats per-virtual-host configs and tunning them

# according to http://forums.gentoo.org/viewtopic.php?t=279860

# Usage:

#    $ scriptname first.domain.com [other.domains.com [yet.another.com] ...]

# This code assumes you keep your virtual hosts under directory structure

# like this:   $VIRTUAL_PREFIX/$mydomain/$LOGS_SUFFIX/

VIRTUAL_PREFIX="\/var\/virtual\/hosts"

LOGS_SUFFIX="logs"

LOGS_NAME="access_log"

STAT_SUFFIX="stats"

SITE_DOMAIN="mysitedomain.com"

cd /etc/awstats

# iterate over each of the virtual hosts:

for mydomain in $@; do

echo processing domain $mydomain...

sed \

 -e "s/^LogFile=.*$/LogFile=\"$VIRTUAL_PREFIX\/$mydomain\/$LOGS_SUFFIX\/LOGS_NAME\"/" \

 -e "s/^SiteDomain=.*$/SiteDomain=\"$SITE_DOMAIN\"/" \

 -e "s/^HostAliases=.*$/HostAliases=\"www.$mydomain $mydomain\"/" \

 -e "s/^DirData=.*$/DirData=\"$VIRTUAL_PREFFIX\/$mydomain\/STAT_SUFFIX\"/" \

 -e "s/^DirIcons=.*$/DirIcons=\"\/awstatsicons\"/" \

    < ./awstats.model.conf > ./awstats.www.$mydomain.conf

mkdir -p $VIRTUAL_PREFIX/$mydomain/$LOGS_SUFFIX

mkdir -p $VIRTUAL_PREFIX/$mydomain/$STAT_SUFFIX

done

echo "Done."

```

(Note: made some changes in the last moment that are not tested -- fix errors and adopt for your own needs!)

Good luck!

yassen

----------

## ckdexter

Great Howto, thanks a lot.

----------

## plainzwalker

This is a great how-to, been trying to get awstats to work for a while and now it does. One problem I have came across however. I tried to go back in to setup a second awstats for a virtual host and its not showing that virtual hosts informatiom, just one for the default server.

I changed all the important information in the new awstats.virtualhostname.conf file and reran the 

```
/usr/share/webapps/awstats/6.1/hostroot/cgi-bin/awstats.pl -config=broadcaster.iwas2.net -update

```

command. And it still shows the same information. Anything that I am missing here?

Thanks

Jeff

----------

## laman

Great HowTo it really helped me a lot. 

But I was wondering if anyone knows how to get GeoIP working under Gentoo. I tried but can't get it to work.

Does anyone has an idee

Greetz

Robert

----------

## jmaltais

Super!  Got it working a couple of minutes.  This program _kills_ webalizer

----------

## radixvir

thanks i also got it working fairly quick

you should also look into the javascript file. it can report information about the users settings but its a little more complex to set up. on ie it takes about 2 seconds to run the script, so you can try removing the plugin detection. I only cared about getting the users screen size so i removed the detectIE and detectNS functions completely. remember to edit the string at the bottom of the file then.

----------

## enobis

 *plainzwalker wrote:*   

> I changed all the important information in the new awstats.virtualhostname.conf file and reran the 
> 
> ```
> /usr/share/webapps/awstats/6.1/hostroot/cgi-bin/awstats.pl -config=broadcaster.iwas2.net -update
> 
> ...

 

Jeff (aka plainzwalker):

Is the name of your awstats config file /etc/awstats/awstats.broadcaster.iwas2.net.conf ???

If so, then what is the output/error message you get when you run awstats.pl from the command line?

----------

## enobis

thanks for the replies, always good to know that the time spent writing has helped others   :Very Happy: 

----------

## _GeG_

hi, just a small addition:

i have an awstats.common.conf, where all common values are set. And in my configuration files for each virtual server, I just use:

```
Include "/etc/awstats/awstats.common.conf"

LogFile="/var/log/apache2/VLOG-xxx-mydomain.com"

SiteDomain="www.mydomain.com"

HostAliases="mydomain.com"

```

btw don't forget to comment out LogFile, SiteDomain and HostAliases in awstats.conmon.conf  :Wink: 

----------

## bravecobra

Watch out guys, AWStats has a possibility to execute arbitrary code on the server.  Have a look here:

http://sourceforge.net/tracker/index.php?func=detail&aid=1110659&group_id=13764&atid=113764

http://www.saintcorporation.com/cgi-bin/demo_tut.pl?tutorial_name=vulnerable_web_program.html&fact_color=doc&tag=#AWStats

That's why I took it off until it's fixed. Maybe we could put a patch into our ebuild? I'm not a perl-guy though.

----------

## monotux

Great howto, thanks!  :Very Happy: 

----------

## deflin39

Nice guide.  The only problem I'm having is with the icons.  I have played with the DirIcons directive with no luck.  I can post whatever config files you'd like.

deflin39

----------

## padukes

Thanks for the great howto! I only had to add one line to my awstats.conf for 6.3:

```
Alias /awstatsicons "/usr/share/webapps/awstats/6.3/htdocs/icon/"
```

Webapp-config seems to just cause more trouble than its worth  :Sad: .  Does anyone know if there's a tool to track what URLs a particular user (IP) requested? Can awstats do this?

Thanks,

P

----------

## deflin39

Could someone plase show me their /etc/apache2/conf/awstats.conf file please so I can compare it to mine.  I got the icons working finally, but I think I opened to big of a hole with my config file

Thanks!

deflin39

----------

## j-m

 *deflin39 wrote:*   

> Could someone plase show me their /etc/apache2/conf/awstats.conf file please so I can compare it to mine.  I got the icons working finally, but I think I opened to big of a hole with my config file
> 
> Thanks!
> 
> deflin39

 

I don´t know what you mean. Icons work out of the box for me with 6.3 (literally copied from postinst-en.txt)

```

Alias /awstats/classes "/usr/share/webapps/awstats/6.3/htdocs/classes/"

Alias /awstats/css "/usr/share/webapps/awstats/6.3/htdocs/css/"

Alias /awstats/icons "/usr/share/webapps/awstats/6.3/htdocs/icon/"

ScriptAlias /awstats/ "/usr/share/webapps/awstats/6.3/hostroot/cgi-bin/"

ScriptAlias /awstats "/usr/share/webapps/awstats/6.3/hostroot/cgi-bin/awstats.pl"

ScriptAlias /awstats.pl "/usr/share/webapps/awstats/6.3/hostroot/cgi-bin/awstats.pl"

<Directory "/usr/share/webapps/awstats/6.3/htdocs">

    Options None

    AllowOverride None

    <IfModule mod_access.c>

        Order allow,deny

        Allow from all

    </IfModule>

</Directory>

<Directory "/usr/share/webapps/6.3/hostroot/cgi-bin">

    Options ExecCGI

    AllowOverride None

    <IfModule mod_access.c>

        Order allow,deny

        Allow from all

    </IfModule>

</Directory>

<Directory "/usr/share/webapps/awstats/6.3/hostroot">

    Options None

    AllowOverride None

    Order allow,deny

    Allow from all

    AuthType Basic

    AuthName AWStats

    AuthUserFile /etc/awstats/.htpasswd

    require valid-user

</Directory>

```

----------

## deflin39

Thanks j-m.

I didn't have the last section in the config file, because I was not password protecting awstats.  The how-to doesn't make it clear that section needs to be there, even if you are not using AUTH.  I just removed the 3 AUTH commands and I get icons now.

deflin39

----------

## SilverOne

Thanks for this mini-howto...

It convinced me to do this without webapp-config...

Now on to postfix-log parsing!

/me hits the search button  :Smile: 

----------

## j-m

I have tweaked this to use MySQL for authentication.

1. You need the appropriate module:

```

# emerge mod_auth_mysql

```

2. Modify /etc/conf.d/apache2 to add the required module:

```

APACHE2_OPTS="-D SSL -D PHP4 -D AUTH_MYSQL"

```

3. Follow the instructions in /etc/apache2/conf/modules.d/12_mod_auth_mysql.conf - select ONE of the database templates (the last one being the most flexible for authentication needs) and create the database using the template. I strongly suggest that you choose some better password for authuser.

Populate the new database with required user/group accounts. 

4. You need to modify the last section of /etc/apache2/conf/awstats.conf

```

<Directory "/usr/share/webapps/awstats/6.3/hostroot">

    Options None

    AllowOverride None

    Order allow,deny

    Allow from all

    AuthName "AWStats MySQL authenticated zone"

    AuthType Basic

    AuthMySQLUser authuser

    AuthMySQLPassword [password]

    AuthMySQLDB auth

    AuthMySQLUserTable users

    AuthMySQLNameField user_name

    AuthMySQLPasswordField user_passwd

# Optional - depends on the selected database template

#    AuthMySQLGroupTable groups

#    AuthMySQLGroupField user_group

# Required! Uncomment ONE of the following lines as appropriate for your config

#    require valid-user

#    require group [groupname]

</Directory>

```

5. Check your Apache config:

```

# apache2ctl -t

```

You should receive Syntax OK message.

6. If the previous steps went OK, you are ready to start:

```

/etc/init.d/apache2 restart

```

7. Point you browser to http://www.yourdomain.tld/awstats/awstats.pl and test MySQL authentication.

8. Enjoy!    :Laughing: 

----------

## j-m

Additional tips for mass hosting:

1. Create default configuration for all domains:

```

cp /etc/awstats/awstats.model.conf /etc/awstats/awstats.include.conf

```

Edit awstats.include.conf to suite you needs. Important! Delete or comment out the lines shown in step 2 from this default configuration.

2. Create a basic template for your domains. It could include only the following lines:

```

LogFile="/usr/bin/logresolvemerge.pl /path/to/domain/logs/VLOG-%YYYY-24-%MM-24-*.log |"

SiteDomain="yourdomain.tld"

HostAliases="www.yourdomain.tld REGEX[yourdomain\.tld$]"

DirData="/path/to/your/stats"

AllowAccessFromWebToAuthenticatedUsersOnly=1

AllowAccessFromWebToFollowingAuthenticatedUsers="[username]"

AllowAccessFromWebToFollowingIPAddresses=""

Include "awstats.include.conf"

```

The last line is important!

NOTE: I am using Apache VLOG format (separate logs for every virtual domain). 

2. Put this into crontab to have all stats updated at once every midnight

```

0 0 * * *       /usr/bin/awstats_updateall.pl now \

-awstatsprog=/usr/share/webapps/awstats/6.3/hostroot/cgi-bin/awstats.pl \

-configdir=/etc/awstats -excludeconf=awstats.include.conf

```

If your cron dislikes backslashes, put it on one line.

3. Enjoy!

----------

## meyer37

Tried unsuccessfully to follow the how-to yet I am still getting a 403 Forbidden error.

Here is my awstats.conf

Anyhelp would be greatly appreciated.

```

Alias /awstats/classes "/usr/share/webapps/awstats/6.3/htdocs/classes/"

Alias /awstats/css "/usr/share/webapps/awstats/6.3/htdocs/css/"

Alias /awstats/icons "/usr/share/webapps/awstats/6.3/htdocs/icon/"

ScriptAlias /awstats/ "/usr/share/webapps/awstats/6.3/hostroot/cgi-bin/"

ScriptAlias /awstats "/usr/share/webapps/awstats/6.3/hostroot/cgi-bin/awstats.pl"

<Directory "/usr/share/webapps/awstats/6.3/htdocs">

    Options None

    AllowOverride None

    <IfModule mod_access.c>

        Order allow,deny

        Allow from all

    </IfModule>

</Directory>

<Directory "/usr/share/webapps/6.3/hostroot/cgi-bin">

    Options ExecCGI

    AllowOverride None

    <IfModule mod_access.c>

        Order allow,deny

        Allow from all

        Allow from 69.21.245.138

    </IfModule>

</Directory>

```

----------

## j-m

 *meyer37 wrote:*   

> Tried unsuccessfully to follow the how-to yet I am still getting a 403 Forbidden error.
> 
> ```
> 
> Alias /awstats/classes "/usr/share/webapps/awstats/6.3/htdocs/classes/"
> ...

 

You are missing the last line:

```

ScriptAlias /awstats.pl "/usr/share/webapps/awstats/6.3/hostroot/cgi-bin/awstats.pl"

```

 *meyer37 wrote:*   

> 
> 
> ```
> 
>     <IfModule mod_access.c>
> ...

 

... is nonsense. Either allow all or allow specific IPs...

----------

## meyer37

I added:

```

ScriptAlias /awstats.pl "/usr/share/webapps/awstats/6.3/hostroot/cgi-bin/awstats.pl"

```

and removed the ip

still no change.

403 forbidden error still appears.

----------

## j-m

 *meyer37 wrote:*   

> I added:
> 
> ```
> 
> ScriptAlias /awstats.pl "/usr/share/webapps/awstats/6.3/hostroot/cgi-bin/awstats.pl"
> ...

 

OK, you have some other error or overriding configuration settings elsewhere in Apache *.conf files, because these settings do work - tested on two servers... Have a look at the log files - the above-quoted message is useless for troubleshooting.

----------

## meyer37

 *j-m wrote:*   

> OK, you have some other error or overriding configuration settings elsewhere in Apache *.conf files, because these settings do work - tested on two servers... Have a look at the log files - the above-quoted message is useless for troubleshooting.

 

Here is the error that appears in /var/log/apache2/error_log:

```
client denied by server configuration: /usr/share/webapps/awstats/6.3/hostroot/cgi-bin/awstats.pl
```

Any ideas on what I need to to or where I went wrong?

----------

## IMC

 *meyer37 wrote:*   

>  *j-m wrote:*   OK, you have some other error or overriding configuration settings elsewhere in Apache *.conf files, because these settings do work - tested on two servers... Have a look at the log files - the above-quoted message is useless for troubleshooting. 
> 
> Here is the error that appears in /var/log/apache2/error_log:
> 
> ```
> ...

 

Well im getting the same problem and I cant figure it out, I cant see anything in the apache conf files to deny running the script and awstats.pl has exec permissions system wide, very odd, but as always, im sure its somethig obvious.

----------

## IMC

 *IMC wrote:*   

> 
> 
> Well im getting the same problem and I cant figure it out, I cant see anything in the apache conf files to deny running the script and awstats.pl has exec permissions system wide, very odd, but as always, im sure its somethig obvious.

 

Ok, I got it to work, sadly though I cant remember what I did, sorry  :Embarassed: 

If I work out what it was, ill post to let you know.

----------

## cbock

thanks! this worked great for me.

i did have to go back and review the .conf files. i had inadvertantly messed up and did not have '6.3-r2' coded properly in my directory structure. :Embarassed:  following the original instructions a second time helped me find my errors.  :Smile:  good luck.

----------

## loke_71

Helped me to get it running in half an hour.

I also wanted seperate log files for each virtual domain, so I had to setup Apache to log seperatly to each virtual domain. 

<VirtualHost *:80>

    ServerName www.example.com

    ServerAlias example.com

    DocumentRoot /www/example.com

ErrorLog /var/log/apache2/example.com/error_log

    CustomLog /var/log/apache2/example.com/access_log 

</VirtualHost>

----------

## HriBB

 *bravecobra wrote:*   

> Watch out guys, AWStats has a possibility to execute arbitrary code on the server.  Have a look here:
> 
> http://sourceforge.net/tracker/index.php?func=detail&aid=1110659&group_id=13764&atid=113764
> 
> http://www.saintcorporation.com/cgi-bin/demo_tut.pl?tutorial_name=vulnerable_web_program.html&fact_color=doc&tag=#AWStats
> ...

 

You could use static html pages only... awstats_buildstaticpages.pl is needed for this but it's not provided by "emerge awstats". 

This is how I do it...

1. download awstats from http://awstats.sourceforge.net/.

2. untar to /usr/local/awstats

3. cp /usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf /etc/awstats/awstats.www.domain.com.conf and modify it apropriately

4. I created /etc/awstats/databases to store all awstats db (DirData="/etc/awstats/databases")

5. mkdir /var/www/www.domain.com/htdocs/stats

6. create awstats.conf for apache and include it in apache2.conf

```
Alias /classes "/usr/local/awstats/wwwroot/classes/"

Alias /css "/usr/local/awstats/wwwroot/css/"

Alias /icon "/usr/local/awstats/wwwroot/icon/"

#

# I only allow classes/ icon/ and css/ because I do not need cgi-bin/awstats.pl

#

<Directory "/usr/local/awstats/wwwroot/icon">

Options None

AllowOverride None

Order allow,deny

Allow from all

</Directory>

<Directory "/usr/local/awstats/wwwroot/classes">

Options None

AllowOverride None

Order allow,deny

Allow from all

</Directory>

<Directory "/usr/local/awstats/wwwroot/css">

Options None

AllowOverride None

Order allow,deny

Allow from all

</Directory>
```

7. first update

```
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www.domain.com -update
```

8. then build static html pages into desired stats dir

```
/usr/local/awstats/tools/awstats_buildstaticpages.pl -config=www.domain.com -dir=/var/www/www.domain.com/htdocs/stats/
```

9. go to /var/www/www.domain.com/htdocs/stats/ and create index.php with header redirect (or html and use meta redirect)

```
<?php header('location: awstats.www.domain.com.html'); ?>
```

10. check if ok -> http://www.domain.com/stats/

Check my stats -> http://hribb.homelinux.com/stats/ slovenian language only

If icons do not work, check the html source where it's searching for them and repair awstats.conf.

I need to figure out how to do a multilingual build.

----------

## wjholden

For some reason I had to "chmod 777 /etc/awstats/awstats.conf".  I'm not sure why, but it works.

Anyrate, I wondered what you guys think is really reasonable for update times, using the cron daemon?  I'm a complete n00b with cron daemons.  This is a modified form of FAQ-COM130 at http://awstats.sourceforge.net/docs/awstats_faq.html , this output produced by crontab -l.

```
0 * * * * /usr/share/webapps/awstats/6.3-r2/hostroot/cgi-bin/awstats.pl -config=gentoobox.rh.ncsu.edu -update >/dev/null
```

Edit: thank you for this helpful howto!!

----------

## wjholden

Hello, I was digging through the /etc/awstats/awstats.conf and noticed this:

```
# AWStats can purge log file, after analyzing it. Note that AWStats is able

# to detect new lines in a log file, to process only them, so you can launch

# AWStats as often as you want, even with this parameter to 0.

# With 0, no purge is made, so you must use a scheduled task or a web server

# that make this purge frequently.

# With 1, the purge of the log file is made each time AWStats update is ran.

# This parameter doesn't work with IIS (This web server doesn't let its log

# file to be purged).

# Change : Effective for new updates only

# Possible values: 0 or 1

# Default: 0

#

PurgeLogFile="/var/log/apache/access_log"
```

I don't remember changing this, and it isn't mentioned in your howto...is this a bug?  PurgeLogFile is a boolean, not a location, so this piece of code won't work.  Changed it to 0 myself.  Can someone check your installation and verify this is a bug in the 6.3-r2 release?

----------

## funkoolow

thanks for the how-to, everything worked great for me, using awstats-6.3-r2  :Very Happy: 

----------

## j-m

 *destuxor wrote:*   

> .
> 
> # Change : Effective for new updates only
> 
> # Possible values: 0 or 1
> ...

 

You are right. I have  filed a bug.  :Wink: 

----------

## wjholden

Thanks!  I just posted something else that I noticed "wrong" with this ebuild to the same bug.

----------

## ryker

I am trying to get this to work with multiple domain names on one server, and I am having problems.  I did deviate from the guide a little by following the suggestion of someone in this thread previously of creating a common configuration file (awstats.common.conf).  My problem is, the stats for the 3 domain names I have are all identical.  I am also getting an error when I run the 

I am running the following command as root.

update command

```
/usr/bin/awstats_updateall.pl now -awstatsprog=/usr/share/webapps/awstats/6.3-r2/hostroot/cgi-bin/awstats.pl -configdir=/etc/awstats -exclude=awstats.common.conf
```

The beginning of the output where the error is:

```
Running '"/usr/share/webapps/awstats/6.3-r2/hostroot/cgi-bin/awstats.pl" -update -config=common -configdir="/etc/awstats"' to update config common

Error: LogFile parameter is not defined in config/domain file

Setup ('/etc/awstats/awstats.common.conf' file, web server or permissions) may be wrong.

Check config file, permissions and AWStats documentation (in 'docs' directory).

```

This error looks like it is still analyzing awstats.common.conf, even though I put it in the -exclude option.  I don't think this is really causing me any problems anyway except for the warning message.

For completeness following are my conf files:

awstats.common.conf

```
LogType=W

LogFormat=1

LogSeparator=" "

DNSLookup=2

DirCgi="/cgi-bin/awstats"

DirIcons="/awstats/icons"

AllowToUpdateStatsFromBrowser=0

AllowFullYearView=2

EnableLockForUpdate=0

DNSStaticCacheFile="dnscache.txt"

DNSLastUpdateCacheFile="dnscachelastupdate.txt"

SkipDNSLookupFor=""

AllowAccessFromWebToAuthenticatedUsersOnly=0

AllowAccessFromWebToFollowingAuthenticatedUsers=""

AllowAccessFromWebToFollowingIPAddresses=""

CreateDirDataIfNotExists=0

BuildHistoryFormat=text

BuildReportFormat=html

SaveDatabaseFilesWithPermissionsForEveryone=0

PurgeLogFile=0

ArchiveLogRecords=0

KeepBackupOfHistoricFiles=0

DefaultFile="index.html"

SkipHosts=""

SkipUserAgents=""

SkipFiles=""

OnlyHosts=""

OnlyUserAgents=""

OnlyFiles=""

NotPageList="css js class gif jpg jpeg png bmp ico swf"

ValidHTTPCodes="200 304"

ValidSMTPCodes="1 250"

AuthenticatedUsersNotCaseSensitive=0

URLNotCaseSensitive=0

URLWithAnchor=0

URLQuerySeparators="?;"

URLWithQuery=0

URLWithQueryWithOnlyFollowingParameters=""

URLWithQueryWithoutFollowingParameters=""

URLReferrerWithQuery=0

WarningMessages=1

ErrorMessages=""

DebugMessages=1

NbOfLinesForCorruptedLog=50

WrapperScript=""

DecodeUA=0

MiscTrackerUrl="/js/awstats_misc_tracker.js"

UseFramesWhenCGI=1

DetailedReportsOnNewWindows=1

Expires=0

MaxRowsInHTMLOutput=1000

Lang="auto"

DirLang="./lang"

ShowMenu=1

ShowMonthStats=UVPHB

ShowDaysOfMonthStats=VPHB

ShowDaysOfWeekStats=PHB

ShowHoursStats=PHB

ShowDomainsStats=PHB

ShowHostsStats=PHBL

ShowAuthenticatedUsers=0

ShowRobotsStats=HBL

ShowWormsStats=0

ShowEMailSenders=0

ShowEMailReceivers=0

ShowSessionsStats=1

ShowPagesStats=PBEX

ShowFileTypesStats=HB

ShowFileSizesStats=0

ShowOSStats=1

ShowBrowsersStats=1

ShowScreenSizeStats=0

ShowOriginStats=PH

ShowKeyphrasesStats=1

ShowKeywordsStats=1

ShowMiscStats=a

ShowHTTPErrorsStats=1

ShowSMTPErrorsStats=0

ShowClusterStats=0

AddDataArrayMonthStats=1

AddDataArrayShowDaysOfMonthStats=1

AddDataArrayShowDaysOfWeekStats=1

AddDataArrayShowHoursStats=1

IncludeInternalLinksInOriginSection=0

MaxNbOfDomain = 10

MinHitDomain  = 1

MaxNbOfHostsShown = 10

MinHitHost    = 1

MaxNbOfLoginShown = 10

MinHitLogin   = 1

MaxNbOfRobotShown = 10

MinHitRobot   = 1

MaxNbOfPageShown = 10

MinHitFile    = 1

MaxNbOfOsShown = 10

MinHitOs      = 1

MaxNbOfBrowsersShown = 10

MinHitBrowser = 1

MaxNbOfScreenSizesShown = 5

MinHitScreenSize = 1

MaxNbOfWindowSizesShown = 5

MinHitWindowSize = 1

MaxNbOfRefererShown = 10

MinHitRefer   = 1

MaxNbOfKeyphrasesShown = 10

MinHitKeyphrase = 1

MaxNbOfKeywordsShown = 10

MinHitKeyword = 1

MaxNbOfEMailsShown = 20

MinHitEMail   = 1

FirstDayOfWeek=1

ShowFlagLinks=""

ShowLinksOnUrl=1

UseHTTPSLinkForUrl=""

MaxLengthOfShownURL=64

HTMLHeadSection=""

HTMLEndSection=""

Logo="awstats_logo6.png"

LogoLink="http://awstats.sourceforge.net"

BarWidth   = 260

BarHeight  = 90

StyleSheet=""

ExtraTrackedRowsLimit=500
```

Two of my domain files

awstats.puglug.calumet.purdue.edu.conf

```
Include "/etc/awstats/awstats.common.conf"

LogFile="/var/log/apache2/access_log"

DataDir="/var/www/puglug.calumet.purdue.edu/awstats"

SiteDomain="puglug.calumet.purdue.edu"

HostAliases="puglug.calumet.purdue.edu puglug"
```

awstats.emssupport.calumet.purdue.edu.conf

```
Include "/etc/awstats/awstats.common.conf"

LogFile="/var/log/apache2/access_log"

DataDir="/var/www/emssupport.calumet.purdue.edu/awstats"

SiteDomain="emssupport.calumet.purdue.edu"

HostAliases="emssupport.calumet.purdue.edu emssupport"
```

Thanks in advance for your help.

----------

## kamikaze04

Really Really great howto!!! It has been really easy with your instructions!!

Thanks!!!!

----------

## ryker

I just noticed the link that is in this guide for more info for combined logs.  I just noticed I need to change my log format for it to work properly.  I'm sure this is my problem.  I'll report back if it worked or not.

----------

## ryker

OK.  It works now.  But I still get an error about my common configuration file even though I specified it in the exclude list.  Is my syntax not correct?

Command I am running as root

```
/usr/bin/awstats_updateall.pl now -awstatsprog=/usr/share/webapps/awstats/6.3-r2/hostroot/cgi-bin/awstats.pl -configdir=/etc/awstats -exclude=awstats.common.conf

```

Error message

```
Running '"/usr/share/webapps/awstats/6.3-r2/hostroot/cgi-bin/awstats.pl" -update -config=common -configdir="/etc/awstats"' to update config common

Error: LogFile parameter is not defined in config/domain file

Setup ('/etc/awstats/awstats.common.conf' file, web server or permissions) may be wrong.

Check config file, permissions and AWStats documentation (in 'docs' directory).
```

After the above error message, it continues with the rest of the domain config files, and all is well.  So, I guess since it works it's not reall that important.  It's just annoying.

----------

## funkoolow

hi again, 

back in this post to ask: where do i need to act to let http://stats.mysite.com points to http://www.mysite.com/awstats/awstats.pl if the specified file does not exist in the specified directory? 

p.s: don't know if this goes too much OT, feel free to delete this msg if so, I just posted here to skip the new-thread-explaing-situation procedure  :Wink: 

----------

## fury

GREAT Howto!

I'm using seperate log files for each virtualhost, but my situation is slightly different in that I do some hosting for friends.  Right now they can access their statistics (i just have to set it up for their domain), which is great.  Password-protecting also works (and is handy if there's an exploit for this software).

I just need to know how to make unique passwords/logins for each site.  Currently, users can go to www.otheruserssite.com/awstats/awstats.pl and put in their passwords, and access OTHER user's site data, which isn't so good.

Any ideas?

----------

## ryker

 *fury wrote:*   

> GREAT Howto!
> 
> I'm using seperate log files for each virtualhost, but my situation is slightly different in that I do some hosting for friends.  Right now they can access their statistics (i just have to set it up for their domain), which is great.  Password-protecting also works (and is handy if there's an exploit for this software).
> 
> I just need to know how to make unique passwords/logins for each site.  Currently, users can go to www.otheruserssite.com/awstats/awstats.pl and put in their passwords, and access OTHER user's site data, which isn't so good.
> ...

 

I''m not sure off hand, but I found this on the awstats website.

```
How:

awstats.pl file must be saved in a web protected realm to force a visitor to enter its username/password to access AWStats CGI program.

Example of directives you can add into Apache to have awstats.pl in a web protected realm:

<Files "awstats.pl">

AuthUserFile /path/to/.passwd

AuthGroupFile /path/to/.group

AuthName "Restricted Area For Customers"

AuthType Basic

require valid-user

</Files>

If you add such directives into a .htaccess file, you must also check that the AllowOverride directive is set to All in Apache config file to allow the use of .htaccess files.
```

Seems like this should do what you want.

----------

## [dmnd]

Thanks j-m!

----------

## jmckay123456789

when this howto was originally written, webapp-config may not have been working so great. But it seemed to do a fine job with my awstats install, and is the way that the gentoo devels intend you to install webapps. So for any of you interested in using webapp-config, I would point you to the howto I wrote after my success:

https://forums.gentoo.org/viewtopic-t-309005.html

----------

## wjholden

http://bri-net.org/?p=74

Found this helpful last weekend.

----------

## boulli

Great howto, got awstats working within 5 minutes  :Cool: 

----------

## linux_girl

1hour later still geting

```

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Apache/2.0.54 (Gentoo/Linux) mod_ssl/2.0.54 OpenSSL/0.9.7e PHP/4.3.11 Server at xxxxxxxxxxxxxxxxxxxx

```

----------

## wjholden

Mmm additional server error sounds like a misconfiguration in /etc/apache2/conf/commonapache2.conf?  If you go to http://yourwebsite.com/awstats/icons/mime/image.png does it throw an error?

Are you trying to use any form of authentication?  I see you're not using mod_auth_mysql, so I'd suppose you're using an htaccess/htpasswd files if you want to authenticate viewers of your statistics.  There could be a problem with those files, and I would check the permissions on them (created/owned by root and not readable by user apache?).

Also, check the ownership of the files - they should all belong to apache:apache.  IIRC Apache will throw a 500 if the process is not able to open a file.

Side note - you might also consider putting a real email address instead of root@localhost into commonapache2.conf while you're there.

----------

## linux_girl

http://vhost.donain.com/awstatsicons/other/hh.png gives a 404

however the *.html made by awstats display well graphs that

use img src=http://vhost.donain.com/awstatsicons/other/hh.png

however i am using somme special recipie for vhsoting :

```

cat apache2.conf|grep -i Inclu

LoadModule include_module                modules/mod_include.so

Include conf/modules.d/*.conf

Include conf/commonapache2.conf

# We include different templates for Virtual Hosting. Have a look in the

#Include conf/vhosts/vhosts.conf

#Include conf/vhosts/dynamic-vhosts.conf

#Include conf/vhosts/virtual-homepages.conf

```

```

#tail of apache2.conf

RewriteEngine On

 # a ServerName derived from a Host: header may be any case at all

 RewriteMap  lowercase  int:tolower

 RewriteCond  %{REQUEST_URI}  !^/icons/

 # Duplicate the above for whatever other system-wide aliases you have

 RewriteCond  /pub/www/hosts/${lowercase:%{SERVER_NAME}} -d

 RewriteRule  ^/(.*)$  /pub/www/hosts/${lowercase:%{SERVER_NAME}}/$1 [L]

 RewriteCond  %{REQUEST_URI}  !^/icons/

 # Duplicate the above for whatever other system-wide aliases you have

 RewriteRule  ^/(.*)$  /pub/www/hosts/default/$1

 # this log format can be split per-virtual-host based on the first field

 LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon

 CustomLog logs/access_log vcommon

```

then i added the awstats directive to /pub/www/hosts/vhost001.domain.com/.htaccess

```

#####################################

##/pub/www/hosts/vhost001.domain.com/.htaccess

#####################################

#

# Directives to allow use of AWStats as a CGI

#

Alias /awstatsclasses "/usr/share/webapps/awstats/6.4/htdocs/classes/"

Alias /awstatscss "/usr/share/webapps/awstats/6.4/htdocs/css/"

Alias /awstatsicons "/usr/share/webapps/awstats/6.4/htdocs/icon/"

ScriptAlias /awstats/ "/usr/share/webapps/awstats/6.4/hostroot/cgi-bin/"

#

# This is to permit URL access to scripts/files in AWStats directory.

#

<Directory "/usr/share/webapps/awstats/6.4/htdocs/">

    Options None

    AllowOverride None

    Order allow,deny

    Allow from all

</Directory>

#

# This is to permit URL access to scripts/files in AWStats directory.

#

<Directory "/usr/share/webapps/awstats/6.4/hostroot/cgi-bin/">

    Options None

    AllowOverride None

    Order allow,deny

    Allow from all

</Directory>

```

EDIT: it works now

----------

## tecknojunky

Damn stupid webapp-config!!!  :Mad:   To make this work, I'm messing up all of my configs because of this idiotic script.

Yeah, yeah.  Don't use it blah blah blah, but why can't we just have the liberty to choose the old way it use to install web stuffs, and letting the users the freedom to set things up like they feel is appropriate, while keeping the feature of being warned when a new version comes up?

This script induce such a level of abstraction, that I'm sure people who never manually configured a web server otherwise don't learn a poop with this.  They get on another's web server and the only excuse they'll be able to provide is "you, know, Gentoo's webapp-config does all that for me.  Maybe you should switch to Gentoo so that I can help you".  Yeah.  Right.  :Rolling Eyes: 

I think I will fork Gentoo, and especially scrap webapp-config  :Razz: 

----------

## linux_girl

 *tecknojunky wrote:*   

> Damn stupid webapp-config!!!   To make this work, I'm messing up all of my configs because of this idiotic script.
> 
> Yeah, yeah.  Don't use it blah blah blah, but why can't we just have the liberty to choose the old way it use to install web stuffs, and letting the users the freedom to set things up like they feel is appropriate, while keeping the feature of being warned when a new version comes up?
> 
> This script induce such a level of abstraction, that I'm sure people who never manually configured a web server otherwise don't learn a poop with this.  They get on another's web server and the only excuse they'll be able to provide is "you, know, Gentoo's webapp-config does all that for me.  Maybe you should switch to Gentoo so that I can help you".  Yeah.  Right. 
> ...

 

i totaly agree with you i lost about  4 hours  to figure out how to make this perl script to work+ the doc isnt up to date => had to figure out why some perl module cry (Geoip city country ...)... + change almost evry wrong alias ...  + unzip the jar to make 3d works + tune the javascript path(screen resolution stats).

 the authors of awstats ebuild is totaly a brain damaged guy.

the awstas isnt that great compared to comerial stats analyser.

i steel had to grep the log file by hand to gather more info.

----------

## linux_girl

PS : the author is an idiot not app-config.

gentoo=not for production server 

just for pepole who want to loose time messing up with their conf and belive in the hype of gcc -O3

----------

## wjholden

Umm Gentoo works great on my boxes here...some people just have better luck than others I guess.  I've never used webapp-config though, so idk.

----------

## fnjordy

The OP is a bit out of date for 6.5, but works nicely with Kerberos authentication, and pulling stats from MySql using mls2clf and mod_sql.

```
<Directory "/usr/share/webapps/awstats/6.5/hostroot/cgi-bin">

    Options ExecCGI

    AllowOverride None

    <IfModule mod_access.c>

        Order allow,deny

        Allow from all

    </IfModule>

    AuthType Kerberos

    AuthName "Kerberos Login"

    KrbServiceName HTTP

    KrbAuthRealms EXAMPLE.COM

    Krb5Keytab  /etc/apache2/keytab

    Require valid-user

</Directory>
```

Modify awstats config file to pipe from mls2clf:

```
LogFile="/usr/local/bin/mls2clf --vhost=www.example.com --time=86400 |"
```

Basic mls2clf configuration: /etc/mls2clf.conf

```

# /etc/mls2clf.conf

# mls2clf database information

#

# note that this file should not be world readable!

username="awstats"

password="password"

hostname="db.example.com"

database="apachelogs"

tablename="access_log"
```

Just need a new ebuild for mls2clf now >>> https://bugs.gentoo.org/show_bug.cgi?id=105466

----------

## newtonian

Hi-

I upgraded from 6.3 to 6.5 and the icons directory in my .conf files were different from what the awstats.conf was pointing to. So I changed the link to the icons in my .conf files with this:

If your your existing 6.3 domain.tld.conf files don't match

your new 6.5 awstats.conf icon alias and you want to change them.

Backup your /etc/awstats directory and try the following command:

```
find . -type f | xargs sed -i '' -e 's@awstatsicon@awstats/icon@g'
```

Just thougt somebody here might find this useful.

Cheers,

----------

## linux_girl

drope awstats it sucks like hell . i now use a php script +mysql to get a better stats handling.

who use apaches vhosts rewriting  and logrotates will fell the pain.

boycote that bad ass perle script that may open a backdoor.  :Smile: 

----------

## newtonian

 *linux_girl wrote:*   

> drope awstats it sucks like hell . i now use a php script +mysql to get a better stats handling.
> 
> who use apaches vhosts rewriting  and logrotates will fell the pain.
> 
> boycote that bad ass perle script that may open a backdoor. 

 

I agree that you have to be careful with awstats, it seems that it often has

security issues.  Updates are very important.  Do you have a link for the php script? 

or is it something you made yourself?

Cheers,

----------

## ben-xo

Having had gentoo + USE='vhosts' + webapp-config + awstats + GeoIP running on a production server for over a year now, i'd like to share the following information...

1) the awstats ebuild sets up awstats in a completely vhost independent way, by adding the following to /etc/apache2/vhosts.d/vhosts.conf:

```
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"
```

which means that http://www.any-web-site-on-your-server.com/awstats will work with no installation necessary into the vhost (excepting that you do need to set up a config file for that vhost). 

NOTE: it's /awstats not /awstats/ . 

NOTE 2: you'll need to change that bit every time you upgrade awstats to the version number of the latest version you have installed. I would recommend doing that AFTER you've updated your awstats.conf files to take into account any new features of your new awstats.

2) the easiest way to set up lots of vhosts with the same type of awstats config is to use *1* awstats config file called 'common.inc' in /etc/awstats/common.inc, and then 1 tiny awstats config file per vhsot in /etc/awstats/, e.g. /etc/awstats/awstats.www.my-website.com.conf

each of these tiny awstats files will look like this:

```
LogFile="/var/log/apache2/VLOG-%YYYY-1-%MM-1-www.my-website.com.log"

SiteDomain="www.cmy-website.com"

Include "common.inc"
```

NOTE: you'll have to change the LogFile line If you're NOT using the default apache log splitter thing which puts 1 log file per vhost per month into /var/log/apache2/.

3) getting Geo-IP working was not obvious, but it was easy. Here's how I did it:

3.1: # emerge -va dev-perl/Geo-IP

You'll notice that currently (dev-perl/Geo-IP-1.25 ) emerge comes up with the following QA notice:

 *Quote:*   

> QA Notice: the following files contain runtime text relocations
> 
>  Text relocations require a lot of extra work to be preformed by the
> 
>  dynamic linker which will cause serious performance impact on IA-32
> ...

 

oh dear. Well, TEXTREL's bugger up my nice gentoo hardened system. Too bad. Good job we're not actually going to be using this module... (read on and you'll see).

put the following in your common.inc (or whatever your main awstats.conf file is called):

```

LoadPlugin="geoip GEOIP_STANDARD /usr/share/GeoIP/GeoIP.dat"

```

now. if you were to update all your awstats, right now, using the command awstats_updateall.pl now, you would see lots of the following:

 *Quote:*   

> Error: Plugin load for plugin 'geoip' failed with return code: Error: Can't locate Geo/IP/PurePerl.pm in @INC (@INC contains: /etc/perl /usr/lib/perl5/site_perl/5.8.7/i686-linux /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.7/i686-linux /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.7/i686-linux /usr/lib/perl5/5.8.7 /usr/local/lib/site_perl . /usr/share/webapps/awstats/6.5/hostroot/cgi-bin/lib /usr/share/webapps/awstats/6.5/hostroot/cgi-bin/plugins) at (eval 6) line 1

 

(showing quite clearly that awstats isn't working right).

A short explanation: there are *3* GeoIP perl modules available, but only one of them - dev-perl/Geo-IP (the commercial MaxMind module; free for various uses) - is in portage. The other two are 'GeoIPFree' (which is a free version of MaxMind one but it's less fully featured) and Geo-IP PurePerl, which is the same as Geo-IP but slightly slower because it's written purely in Perl. However, this is the one which awstats is trying to use AND since it can't possibly contain any TEXTRELs, it should definitely work on a hardened system. But... it's not in portage. So here's how we install it:

```

# perl -MCPAN -e 'shell'

```

if this is the first time you've ever used the CPAN shell, you'll have to answer a lot of stupid questions now. The defaults are most likely to be fine, so press enter a lot. Read them anyway to see what it's doing and to be reassured that I'm right about that. Eventually you will be asked to choose a CPAN mirror; follow the instructions.

Ok now we have CPAN set up, type 

```

cpan> install Geo::IP::PurePerl

```

... and watch the magic happen.

NOTE: if you're fed up with CPAN's terrible command line interface (tried pressing backspace yet?) you can type install Bundle::CPAN and then reload cpan and the world will become a slightly brighter place.

**** NOTE 2 ****: since we just installed Geo::IP::Free it outside of portage, if you ever update perl, when you run perl-cleaner to update and fix your modules, it will bitch about this one (without updating it), and you'll have to reinstall the perl module using these instructions, or awstats will mysteriously stop working...

That's it!

----------

## BlackB1rd

@ben-xo: Thanks for sharing these instructions with us. But one thing, I don't get any error related to PurePerl without installing this module through CPAN? Can't say for now if it actually works, I only get "unknown" in the GeoIP column for now. But as far as I understand this would take a while since it doesn't parse any old records.

----------

## ben-xo

 *BlackB1rd wrote:*   

> @ben-xo: Thanks for sharing these instructions with us. But one thing, I don't get any error related to PurePerl without installing this module through CPAN? Can't say for now if it actually works, I only get "unknown" in the GeoIP column for now. But as far as I understand this would take a while since it doesn't parse any old records.

 

Perhaps these dependencies were fixed in AWStats 6.6 which just hit portage stable in the last few days. Or perhaps you have it installed already by something else, or for some other reason, or a new version of GeoIP has fixed the problem. 

In any case, if you don't get any of the errors mentioned, then you don't need to worry about fixing them.

----------

## Herring42

Just a quick note: 

Install the perl module thus:

```

g-cpan -i Geo::IPfree

```

Thanks for the HowTo. WebApp-config still doesn't help with this ebuild  :Confused: 

----------

## Insanity5902

 *Herring42 wrote:*   

> Just a quick note: 
> 
> Install the perl module thus:
> 
> ```
> ...

 

why not just

```

emerge -va Geo-IP

```

This way it is now managed and updated with portage?  :Smile: 

----------

## ben-xo

 *Insanity5902 wrote:*   

>  *Herring42 wrote:*   Just a quick note: 
> 
> Install the perl module thus:
> 
> ```
> ...

 

if you read a few posts up, to my guide, there's an explanation that that's the wrong module.

edit: just checked; Geo-IP-Free is still not in portage.

----------

## Insanity5902

read these two pages

http://www.maxmind.com/geoip/api/c.shtml

and

http://www.cpan.org/modules/by-authors/id/T/TJ/TJMATHER/Geo-IP-1.25.readme

Unless I am misunderstanding something,  the geo-ip is all the same program, just the subscription gives you access to the update and upgraded database.  The one in portage uses the free one, and then with a few changes you can move to the subscrtion based geoip.  So if you are fine with the montly updates, then the Geo-IP base install is perfectly legal and works.  Again, it is now managed by portage so all updates go through it.

Please explain to me if I am missing something.  I am using it this way, I am pretty sure I am legal, and I know for a fact it works.

*Also Note*  I am don't get the QA notice, but then again I also am not using a hardened system.

----------

## ben-xo

 *Insanity5902 wrote:*   

> read these two pages
> 
> http://www.maxmind.com/geoip/api/c.shtml
> 
> and
> ...

 

It's not a matter of legality, it's that the Perl modules are named differently.

One is Geo::IP and the other is Geo::IPFree

----------

## Insanity5902

So it isn't the wrong modules, just one you choose not to implement.  I see.

----------

## ben-xo

 *Insanity5902 wrote:*   

> So it isn't the wrong modules, just one you choose not to implement.  I see.

 

You'll notice that my guide includes "emerge dev-perl/Geo-IP" as part of the instructions! At the time of writing, this was not enough to get Geo-IP working properly with AWStats on a hardened system. dev-perl/Geo-IP keeps GeoIP.dat up to date. But it's a binary module, and AWStats is (or was) trying to load the pure-perl module. If you don't see any perl problems at step 3, you don't need to manually install Geo::IPFree.

There are at least 3 different Geo-IP modules in CPAN, I had a look. Fixing AWStats, Geo-IP or the ebuilds to make this all work without *possibly* needing to use CPAN is beyond the scope of this article

----------

## sleepingsun

Thanks a lot working great to me ! i use version 6.5-r1 ! 

I sow it that 6.6 is out and its blocked on my gentoo 2006.1 and i get massage that is unstable is it true ? 

Friendly

Nightwisher

----------

## Mousee

 *sleepingsun wrote:*   

> Thanks a lot working great to me ! i use version 6.5-r1 ! 
> 
> I sow it that 6.6 is out and its blocked on my gentoo 2006.1 and i get massage that is unstable is it true ? 
> 
> Friendly
> ...

 

http://awstats.sourceforge.net/

 *Quote:*   

> 
> 
> AWStats 6.6 beta is ready for tests
> 
> Fri, 21 Jul 2006 23:41:25
> ...

 

It's still Beta, so obviously it's not stable.

----------

## Narusegawa

@ben-xo: Thats a great mini-mini-howto. Will be using it later on as a basis for my own multiple domain/sub-domain setup and see how it goes.

5 domains, each with 2-10 sub-domains each. With the least number of configuration files to change, and each one linked to its on awstats (to prevent one sub-domain seeing a different ones awstats). Sadly not fully dymanic (in that I'll have to create a file for each sub-domain that gets added) but thats okay. Hell Apache2 needs a restart/graceful after adding a sub-domain anyway.

----------

## infecticide

I'm getting these errors when trying to update the database:

```

/usr/share/webapps/awstats/6.5-r1/hostroot/cgi-bin/awstats.pl -config=vhost.domain.net -update

Error Opening file /pathto/GeoIPRegion.dat

Error Opening file /pathto/GeoIPCity.dat

Update for config "/etc/awstats/awstats.vhost.domain.net.conf"

With data in log file "/var/log/apache2/vhost.domain.net-access_log"...

Phase 1 : First bypass old records, searching new record...

Searching new records from beginning of log file...

Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...

Can't call method "city" on an undefined value at /usr/share/webapps/awstats/6.5-r1/hostroot/cgi-bin/plugins/geoip_city_maxmind.pm line 4533, <LOG> line 2.

```

Little help?

----------

## Mousee

 *infecticide wrote:*   

> I'm getting these errors when trying to update the database:
> 
> ```
> 
> /usr/share/webapps/awstats/6.5-r1/hostroot/cgi-bin/awstats.pl -config=vhost.domain.net -update
> ...

 

It appears you have the GeoIP module enabled from these errors. However there are 2 GeoIP modules.. the GeoIPFree and GeoIP (Pay) modules. If you're trying to use the standard GeoIP (Pay) module, then you need to actual buy it. If you're trying to use the GeoIP:Free module, then you might need to install it first. It's a Perl module I believe... I haven't touched GeoIP in a while so I don't honestly recall, but a quick forum search here might turn up some hints  :Smile: 

You could alternately just disable GeoIP.. unless you really need such data.

----------

## infecticide

It almost appears as though its expecting the path the GeoIP database to be defined somewhere.

Any idea where I would do that?

----------

## Mousee

 *infecticide wrote:*   

> It almost appears as though its expecting the path the GeoIP database to be defined somewhere.
> 
> Any idea where I would do that?

 

Like I said, it depends on which version of GeoIP you're trying to use.

All of the settings are in your awstats config file though.

Just as an example:

 *Quote:*   

> 
> 
> # Plugin: GeoIP_Org_Maxmind
> 
> # Perl modules required: Geo::IP (from Maxmind)
> ...

 

The GeoIP options are near the bottom of your config file.

If you're trying to use Geo::IPFree and are getting this same error, then I'm sorry but I have no idea. The only thing I can think of in this case, is that you don't have the Geo::IPFree Perl module installed.

----------

## Sakkath

Thank you for the HOWTO.  All the other ones I found, including on gentoo-wiki, were no good, they just took unnecessary steps and lead to unwanted results.  You should just change a few numbers to make it work with the newest version and put it on gentoo-wiki.com :-p.  Having it on the gentoo.org/doc would be even better :-p.

----------

## spOOwn

Nice job, this howto works well to for me !! I added GeoIP and GeoIPCity plugin, and it is really interresting statistique on our web site ! Great job !

----------

## Lori

 *IMC wrote:*   

>  *IMC wrote:*   
> 
> Well im getting the same problem and I cant figure it out, I cant see anything in the apache conf files to deny running the script and awstats.pl has exec permissions system wide, very odd, but as always, im sure its somethig obvious. 
> 
> Ok, I got it to work, sadly though I cant remember what I did, sorry 
> ...

 

It would be very useful for me, as I get the same problem...  :Sad: 

----------

## moon604

 *meyer37 wrote:*   

> Tried unsuccessfully to follow the how-to yet I am still getting a 403 Forbidden error.
> 
> Here is my awstats.conf
> 
> Anyhelp would be greatly appreciated.
> ...

 

if you get 403 forbidden errors remove the <ifmodule mod_access.c> and corresponding </ifmodule> tags. with the latest changes in the apache2 config layout those tags dont trigger anymore and those the crucial allow from all option gets ignored.

----------

## newtonian

 *moon604 wrote:*   

> 
> 
> if you get 403 forbidden errors remove the <ifmodule mod_access.c> and corresponding </ifmodule> tags. with the latest changes in the apache2 config layout those tags dont trigger anymore and those the crucial allow from all option gets ignored.

 

How about this:

```

# change

<Directory "/usr/share/webapps/awstats/6.5/htdocs">

    Options None

    AllowOverride None

    <IfModule mod_access.c>

        Order allow,deny

        Allow from all

    </IfModule>

</Directory>

# to

<Directory "/usr/share/webapps/awstats/6.5/htdocs">

    Options None

    AllowOverride None

#    <IfModule mod_access.c>

        Order allow,deny

        Allow from all

#    </IfModule>

</Directory>

```

Also <IfModule mod_auth.c> has changed to <IfModule mod_auth_basic.c> if you use basic authentication.

Hope this helps.  It got me through the Apache2.0 -> 2.2 upgrade.

Cheers,

----------

## biggyL

Hello All,

using this nice howto and other users notes I've installed and run an new installation of awstats.

Enjoy my updated Mini-Howto (please check and comment  :Smile: ):

1) Add "net-www/awstats vhosts" to  /etc/portage/package.use

2) # emerge -av awstats

3) # cp /usr/share/webapps/awstats/6.5-r1/postinst-en.txt /etc/apache2/awstats.conf

4) Add these lines to /etc/apache2/awstats.conf:

<Directory "/usr/share/webapps/awstats/6.5-r1/hostroot">

    Options None

    AllowOverride None

    Order allow,deny

    Allow from all

    AuthType Basic

    AuthName AWStats

    AuthUserFile /etc/awstats/users.pwd

    require valid-user

</Directory>

4a) If there is no icons and graphs, do:

if you get 403 forbidden errors remove the <ifmodule mod_access.c> and corresponding </ifmodule> tags. with the latest changes in the apache2 config layout those tags dont trigger anymore and those the crucial allow from all option gets ignored. 

Change: 

<Directory "/usr/share/webapps/awstats/6.5/htdocs"> 

    Options None 

    AllowOverride None 

    <IfModule mod_access.c> 

        Order allow,deny 

        Allow from all 

    </IfModule> 

</Directory> 

To: 

<Directory "/usr/share/webapps/awstats/6.5/htdocs"> 

    Options None 

    AllowOverride None 

#    <IfModule mod_access.c> 

        Order allow,deny 

        Allow from all 

#    </IfModule> 

</Directory> 

Also <IfModule mod_auth.c> has changed to <IfModule mod_auth_basic.c> if you use basic authentication. 

5) Add he following to /etc/apache2/httpd.conf:

Include /etc/apache2/awstats.conf

6) Create user for viewing stats:

htpasswd2 -c /etc/awstats/users.pwd adminuser

7) Make config file for every virt. domain:

# cp /etc/awstats/awstats.model.conf /etc/awstats/awstats.yourdomain.com.conf

 :Cool:  Create directory for storing stats for every virt. domain

# mkdir -p /your_virt_host_files_location/stats

9) Now edit /etc/awstats/awstats.yourdomain.com.conf file:

LogFile="/var/log/apache2/yourdomain.com-access_log"

SiteDomain="yourdomain.com"

# HostAliases (any aliases your site may have) 

HostAliases="www.yourdomain.com another.alias.com"

# DirData (AWStats database where your results will be stored. This has to be writable by the Apache user if the AllowToUpdateStatsFromBrowser option is turned on.) 

DirData="/your_virt_host_files_location/stats"

DirIcons="/awstats/icons"

9a) Make acronjob (run every hour):

0 * * * * /usr/share/webapps/awstats/6.5-r1/hostroot/cgi-bin/awstats.pl -config=yourdomain.com -update >/dev/null

Also if using logrotate make sure your /etc/logrotate.d/apache2 contains prerotate...endscipt directions:

/var/log/apache2/*log {

  missingok

  notifempty

  sharedscripts

  prerotate

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

  endscript

  postrotate

  /etc/init.d/apache2 reload > /dev/null 2>&1 || true

  endscript

}

10) You are now ready to build your statistic files for the first time, execute the following command: 

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

Update for config "/etc/awstats/awstats.yourdomain.com.conf"

With data in log file "/var/log/apache2/yourdomain.com-access_log"...

Phase 1 : First bypass old records, searching new record...

Searching new records from beginning of log file...

Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...

Jumped lines in file: 0

Parsed lines in file: 253444

 Found 284 dropped records,

 Found 1 corrupted records,

 Found 0 old records,

 Found 253159 new qualified records.

Restart Apache so that your configuration changes will be take affect: 

# /etc/init.d/apache2 restart 

11) Now go to http://yourdomain.com/awstats/awstats.pl

Enjoy!!!

References:

https://forums.gentoo.org/viewtopic-t-279860-postdays-0-postorder-asc-highlight-awstats-start-75.html

http://blog.codefront.net/2004/08/28/setting-up-awstats-on-gentoo/

http://awstats.sourceforge.net/docs/awstats_faq.html

----------

## biggyL

Hello All,

Please correct me if I'm wrong, but if I want to create separate users for each virtual domain I'll add to /etc/awstats/awstats.mydomain.com.conf:

```

AllowAccessFromWebToAuthenticatedUsersOnly=1

AllowAccessFromWebToFollowingAuthenticatedUsers="user1 [user2 ...]"

```

right?

Or there is another way to do it?

----------

## v1pEr

biggyL's guide worked perfectly, except I had to browse to http://yourdomain.com/cgi-bin/awstats.pl instead of http://yourdomain.com/awstats/awstats.pl

Thank you so much for this guide!

----------

