# trouble setting up awstats

## Elleni

I am trying to setup awstats following this instructions on gentoo wiki. 

My first question would be, if I understood it correctly that if I have multiple domains, I setup these variables: 

```
SiteDomain="mydomain1.com"

HostAliases="localhost 127.0.0.1 REGEX[mydomain1\.com$] REGEX[mydomain2\.com$]
```

The wiki states: 

```
Also, awstats needs to store its database somewhere. Gentoo has created /var/lib/awstats for this use, but it can be stored anywhere. Make sure the permissions are set so that the apache user can write to it
```

So I did 

```
chown apache:apache /var/lib/awstats/
```

Is this correct?

Then I am supposed to issue

```
awstats.pl -config=stats.mydomain.com -update -showdropped
```

But this should be 

```
awstats.pl -config=mydomain.com -update -showdropped
```

 as the config file was named awstats.mydomain.com following the wiki article and not awstats.stats.mydomain.com, right? Else awstats.pl states 

```
Error: Couldn't open config file "awstats.stats.mydomain.com.conf", nor "awstats.conf", nor "stats.mydomain.com" after searching in path "/usr/bin, /etc/awstats, /usr/local/etc/awstats, /etc, /etc/opt/awstats, stats.mydomain.com": No such file or directory
```

By issuing 

```
awstats.pl -config=example.com -update -showdropped
```

 I get 

```
Warning: Can't find language files for "en". English will be used.

Error: Plugin init for plugin 'geoip' failed with return code: Error: Failed to create gi object for datafile=/usr/share/GeoIP/GeoIP.dat

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

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

```
ls -l /usr/share/GeoIP/

total 0
```

How can I avoid the Language warning message? Setting Lang=de or en does not help. 

Not knowing what the problem with GeoIP is I commented the corresponding line out

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

after having checked, that chown apache:apache /usr/share/GeoIP did not change anything.

Now I get: 

awstats.pl -config=mydomain.com -update -showdropped

```
Warning: Can't find language files for "en". English will be used.

Create/Update database for config "/etc/awstats/awstats.mydomain.com.conf" by AWStats version 7.4 (build 20150714)

From data in log file "/var/log/apache2/access_log"...

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

Searching new records from beginning of log file...

AWStats did not find any valid log lines that match your LogFormat parameter, in the 50th first non commented lines read of your log.

Your log file /var/log/apache2/access_log must have a bad format or LogFormat parameter setup does not match this format.

Your AWStats LogFormat parameter is:

%virtualname %host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot

This means each line in your web server log file need to have the following personalized log format:

%virtualname %host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot

And this is an example of records AWStats found in your log file (the record number 50 in your log):

127.0.0.1 - - [10/Nov/2019:11:14:42 +0100] "OPTIONS * HTTP/1.0" 200 -

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

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

So what would be a working LogFormat parameter, that would correspond with my default apache access_log entries configuration?

If anyone can help me to sort those misconfigurations out, I would be very glad. Trying to follow the wiki I seem not able to set this up correctly.

----------

## Elleni

Reading the wiki again I see: 

 *Quote:*   

> For one, awstats assumes that vhosts aren't used. When using apache's default combined vhost logs for example, awstats will fail to run.
> 
> Assume apache's combined LogFormat is setup as follows: 
> 
> Apache's LogFormat
> ...

 

Maybe this is my problem? I have no idea where to check apache's LogFormat configuration. I can only say, that it must be default, as I did not touch it.

----------

## sliwowitz

1. I was able to make GeoIP work by manually downloading the file to a custom directory

```
mkdir /usr/local/share/GeoIP

cd /usr/local/share/GeoIP

wget https://mirrors-cdn.liferay.com/geolite.maxmind.com/download/geoip/database/GeoIP.dat.gz

gunzip GeoIP.dat.gz
```

and changing the file location line in awstats.yoursite.conf to

```
LoadPlugin="geoip GEOIP_STANDARD /usr/local/share/GeoIP"
```

2. The apache LogFormat configuration is in /etc/apache2/modules.d/00_mod_log_config.conf. Comment out the "CustomLog /var/log/apache2/access_log common" line, and uncomment the "CustomLog /var/log/apache2/access_log combined" line near the bottom of the file. You will also have to flush/rotate (or just remove) the old log files, and restart apache.

----------

