AWstats + Apache + Webmin on Debin etch mini-HOWTO

AWstats is a good replacement of Analog and Webalizer: it provide a good interface, and can analyze different type of log files, including HTTP, FTP and SMTP. It is not too difficult to setup under Debian etch, but need some tricky skill. On the other, AWstats provide an official Webmin module. So may we make use of both Webmin and AWstats, for a handy configuration and management?

This mini-HOWTO will cover the required step for installing AWstats and its Webmin module, also a simple example for how to make use all of this.

Install required packages

Install AWstats on Debian etch is pretty simple:

apt-get install awstats libgeo-ipfree-perl libnet-xwhois-perl

I will assume you have install Webmin successfully.

Log into Webmin interface (e.g. https://www.example.com:10000), go to Webmin -> Webmin Configuration -> Webmin Modules -> Install, choose From ftp or http URL and paste the URL provided by AWstats (from http://awstats.sourceforge.net/): http://awstats.sourceforge.net/files/awstats-1.8.wbm, then click the Install Module. Webmin will download and install it for you.

Moreover, reconfigure the menu position of AWstats module by accessing Webmin -> Webmin Configuration -> Reassign Modules, change AWStats Logfile Analyzer from System to Server, so you can find it as like as Webalizer module.

System setup for AWstats and Apache

Before we kick start the configuration and setup, it is better to have some global idea about what Debian's AWstats package have done for us (yes, they are a bit different from AWstats in tarball version):

  • Directory for Documentation: /usr/share/doc/awstats/. You always need to have a look about README.Debian for detail instructions.
  • Directory for CGI: /usr/lib/cgi-bin/. That's means you should configure your Apache's CGI working directory to here (e.g. /cgi-bin) in order to browse the AWstats result.
  • AWstats setup file for Apache: /etc/apache2/conf.d/awstats. You should copy /usr/share/doc/awstats/examples/apache.conf as this file, in order to setup AWstats in Debian's style.
  • Directory for AWstats site configuration files: /etc/awstats. Configure files should name in format of awstats.domain.conf, where domain is your target domain for report generation. You can copy /etc/awstats/awstats.conf as reference. Moreover, we should rename this /etc/awstats/awstats.conf as awstats.model.conf for Webmin module friendly.
  • Directory for Cached result: /var/lib/awstats. This is reconfigured in case for Debian style, when you use /etc/awstats/awstats.conf as sample of your custom configuration file.

So let's start the pre-setup. First of all, copy the AWstats's Apache configuration file to correct location, and restart Apache:

cp /usr/share/doc/awstats/examples/apache.conf /etc/apache2/conf.d/awstats
/etc/init.d/apache2 restart

Now, access your AWstats page (e.g. http://example.com/cgi-bin/awstats.pl) from browser and you should have some error message about your setup. BTW, at this moment we just hope to confirm the correct setup of Apache, therefore this error message is what we hoping for.

Next, prepare your site configuration file for AWstats (as an example, I will setup AWstats for http://example.com/, so this file will called as /etc/awstats/awstats.example.com.conf); moreover, the default sample file for Debian is not Webmin module friendly, so let rename it, too:

cd /etc/awstats
mv awstats.conf awstats.model.conf
cp awstats.model.conf awstats.example.com.conf

Edit /etc/awstats/awstats.example.com.conf and give the minimum setup to this file. Change SiteDomain as below:

SiteDomain="example.com"

Access http://example.com/cgi-bin/awstats.pl once again and a page with empty log result should show out.

If it complain with missing site configuration file, try to access with http://example.com/cgi-bin/awstats.pl?config=example.com and should give you the correct result.

Up to this point, your environment should setup correctly, for both AWstats and Apache. Let's move to the next step: using Webmin for handy-and-detail configuration.

Per-site configuration with Webmin

Access your Webmin page (e.g. https://example.com:10000), go to System -> AWStats Logfile Analyzer (our new path for AWstats module). Webmin should complain with the incorrect setup of AWstats module, so click the Module Config and setup as below:

  • Absolute filesystem path to AWStats update statistics command: /usr/lib/cgi-bin/awstats.pl.
  • Absolute or relative URL path to AWStats CGI: /cgi-bin/awstats.pl.
  • Sample AWStats configuration file: /etc/awstats/awstats.conf.
  • Path for Maxmind GeoIP country database file: /usr/share/GeoIP/GeoIP.dat.

After save the global setup, AWstats module page should show out correctly. Since we have already setup a demo file for our domain http://example.com/, now the page should show out 1 configure setup for it. Click the Edit/Delete config and follow the below setup:

  • LogFile: /var/log/apache2/access.log.
  • LogType: W (Web server log file).
  • LogFormat: 1.
  • PLUGINS SETUP SECTION -> tooltips: on, no parameter.
  • PLUGINS SETUP SECTION -> decodeutfkeys: on, no parameter.
  • PLUGINS SETUP SECTION -> hashfiles: on, no parameter.
  • PLUGINS SETUP SECTION -> geoipfree: on, /usr/share/GeoIP/GeoIP.dat.
  • PLUGINS SETUP SECTION -> userinfo: on, no parameter.
  • PLUGINS SETUP SECTION -> hostinfo: on, no parameter.

Back to the main menu, click Update to generate your report, and click View to enjoy with the result :)


Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <h1> <h2> <h3> <h4> <h5> <h6> <em> <strong> <code> <del> <blockquote> <q> <sub> <p> <br> <ul> <ol> <li> <dl> <dt> <dd> <a> <b> <u> <i> <sup> <acronym> <pre> <img>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Images can be added to this post.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.