# Total AWStats confusion

## fourhead

I just emerged AWStats on my webserver, hosting several vhosts. I must say, I'm _very_ confused about the whole AWStats process. I'd like to have awstats working as a CGI, so I can just open www.mydomain.de/stats and I would see my webserver stats for my domain. So far, so good - but how do I do that? I understand I need several conf files in /etc, named awstats.mydomain1.conf, awstats.mydomain2.conf and so forth. Then, I'd have to put awstats.pl into my webserver directory, where the homepage is stored. In my case, this would be /home/mydomain/www/stats/awstats.pl. What I don't know how to do it is: How do I have to config apache so that it executes the .pl script? Also, awstats needs some other files like icons etc, they are all stored somehere in /usr/share ... I believe I could symlink these dirs to my homepage dir, or I could tell awstats somehow where to find these files?

I'd be glad if someone could give me some hints, especially with apache config, I'm a little stuck with that.

Tom

----------

## steveb

 *elektrohirn wrote:*   

> I just emerged AWStats on my webserver, hosting several vhosts. I must say, I'm _very_ confused about the whole AWStats process. I'd like to have awstats working as a CGI, so I can just open www.mydomain.de/stats and I would see my webserver stats for my domain. So far, so good - but how do I do that? I understand I need several conf files in /etc, named awstats.mydomain1.conf, awstats.mydomain2.conf and so forth. Then, I'd have to put awstats.pl into my webserver directory, where the homepage is stored. In my case, this would be /home/mydomain/www/stats/awstats.pl. What I don't know how to do it is: How do I have to config apache so that it executes the .pl script? Also, awstats needs some other files like icons etc, they are all stored somehere in /usr/share ... I believe I could symlink these dirs to my homepage dir, or I could tell awstats somehow where to find these files?
> 
> I'd be glad if someone could give me some hints, especially with apache config, I'm a little stuck with that.
> 
> Tom

 

assuming you have apache2 as your server and you have installed awstats 6.1. add this to /etc/apache2/conf/apache2.conf:

```
#

# Directives to allow use of AWStats as a CGI

#

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

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

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

ScriptAlias /stats/ "/usr/share/webapps/awstats/6.1/hostroot/cgi-bin/"

#

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

#

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

    Options +FollowSymLinks

    AllowOverride None

    Order allow,deny

    Allow from all

</Directory>

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

    Options +FollowSymLinks

    AllowOverride None

    Order allow,deny

    Allow from all

</Directory>

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

    Options +FollowSymLinks

    AllowOverride None

    Order allow,deny

    Allow from all

</Directory>
```

then create the diffrend awstats.domain1.conf files in /etc/awstats and then restart apache2.

that should do the trick.

if you want to protect the access to awstats, then add something like this to /etc/apache2/conf/apache2.conf:

```
<Files "awstats.pl">

    AuthUserFile /usr/share/webapps/awstats/6.1/hostroot/cgi-bin/.htpasswd

    AuthName "Restricted Area For AWStats"

    AuthType Basic

    AuthAuthoritative On

    Require valid-user

    Options +ExecCGI

    DirectoryIndex awstats.pl

</Files>
```

and then you need to add each user who has access into /usr/share/webapps/awstats/6.1/hostroot/cgi-bin/.htpasswd with the htpasswd2 application.

depending on you setup, maybe you need to change the permission for certain directories:

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

chmod 755 /usr/share/webapps/awstats/6.1/hostroot/cgi-bin/{lang,lib,plugins}
```

to get .pl files (perl files) to execute on apache, you need mod_perl (for apache < 2.0). on apache2 this is already included (i think).

cheers

SteveB

----------

## fourhead

Wow, thanks a lot, that will definitely help me. Am I right in asuming that those aliases are some kind of symlink-alikes, so when the awstats.pl tries to load something from the directory /awstatsclasses then Apache2 would redirect it to /usr/share/web..." ?? And ScriptAlias means when a user accesses www.mydomain.de/stats Apache would redirect this request to /usr/share/... where the script is located right? That would be a perfect setup, I'll check it out! Thanks again!

Tom

----------

## fourhead

Hello,

I just tried it and it works perfectly! Thank you again for that. I'll read trough the config to fully understand it for myself. There's one little problem tough, the bars in the statistics should be colored, but awstats.pl seems to not find the images that are used to color the bars, so all bars are just white. How's that?

Tom

----------

## steveb

 *elektrohirn wrote:*   

> Hello,
> 
> I just tried it and it works perfectly! Thank you again for that. I'll read trough the config to fully understand it for myself. There's one little problem tough, the bars in the statistics should be colored, but awstats.pl seems to not find the images that are used to color the bars, so all bars are just white. How's that?
> 
> Tom

 no. it does not find the icons. check again for the icons configuration (or maybe you need to force a refresh of your browser).

cheers / Gruss

Steve

----------

## fourhead

Hmm I'll look where the icons are stored and check the link. Ok one last question. How do I teach apache that when I enter www.mydomain.de/stats that it should load the awstats.pl? In commonapache2.conf, there's a section

```

<IfModule mod_dir.c>

    DirectoryIndex index.html index.php index.shtml index.cgi index.pl index.htm awstats.pl

</IfModule>

```

I thought I could just add awstats.pl there, but it didn't work out. May a symlink or so work?

----------

## steveb

maybe a script alias or a rewrite rule would do the trick?

cheers

steve

----------

## fourhead

I'm afraid I need some further assistance. I tried everything imaginable, but I didn't manage to config Apache in a way that I could just enter "www.mydomain.de/stats" in a browser to open my statisitcis - I always have to explicitely add "/awstats.pl". I tried everything from linking index.pl -> awstats.pl, changing the ScriptAlias, directly linking /stats to awstats.pl and so forth, but it just didn't work out. Can somebody help me out please?

Tom

----------

## steveb

 *elektrohirn wrote:*   

> I'm afraid I need some further assistance. I tried everything imaginable, but I didn't manage to config Apache in a way that I could just enter "www.mydomain.de/stats" in a browser to open my statisitcis - I always have to explicitely add "/awstats.pl". I tried everything from linking index.pl -> awstats.pl, changing the ScriptAlias, directly linking /stats to awstats.pl and so forth, but it just didn't work out. Can somebody help me out please?
> 
> Tom

 There you go. The first alias needed is:

```
ScriptAlias /stats "/usr/share/webapps/awstats/6.1/hostroot/cgi-bin/awstats.pl"
```

This adds /stats as an alias to the awstats.pl script.

the next needed alias is:

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

this is needed, because awstats will look for /awstats.pl and without the alias it would not display any statistics.

complete addition to /etc/apache2/conf/apache2.conf:

```
#

# Directives to allow use of AWStats as a CGI

#

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

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

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

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

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

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

#

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

#

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

    Options +FollowSymLinks

    AllowOverride None

    Order allow,deny

    Allow from all

</Directory>

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

    Options +FollowSymLinks

    AllowOverride None

    Order allow,deny

    Allow from all

</Directory>

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

    Options +FollowSymLinks

    AllowOverride None

    Order allow,deny

    Allow from all

</Directory>
```

this will work for what you wanted, but will not allow you to use http://www.mydomain.de/stats?conf=www.another-domain.de syntax. you would then still need to use http://www.mydomain.de/awstats/awstats.pl?conf=www.another-domain.de if you want to open another statistics. or you could write an rewrite rule.

cheers

SteveB

----------

## fourhead

Hello, thank you very much for that. Indeed I tried both ScriptAlias for myself, but never got the idea to put them both together  :Smile:  I'll reconfig Apache then, thanks again!

Tom

----------

## steveb

let us know if this is working for you.

cheers

SteveB

----------

## fourhead

Yes, it works perfectly now! Thank you very much! Would never have worked that out without your help I guess.

Tom

----------

## steveb

 *elektrohirn wrote:*   

> Yes, it works perfectly now! Thank you very much! Would never have worked that out without your help I guess.
> 
> Tom

 Locker  :Wink: 

Gruss

Steve

----------

## fs_mariner

Excellent, your very thourough and you helped me a lot.  Thanks.

 *Quote:*   

> Alias /awstatsicons "/usr/share/webapps/awstats/6.1/htdocs/icon/"

 

Needs to be:

Alias /awstatsicon "/usr/share/webapps/awstats/6.1/htdocs/icon/"

For the icons to show up... just an "s" on awstatsicons needs to be removed.

Thanks again!

----------

