AWstats, Plesk 8 and suexec

recently handgestrickt tried to install the newest version of AWstats following our internal tutorial. later while testing, we got a lot of "Error 500: Premature end of script headers" and in tail -10 /var/log/apache/suexec.log we found something like "command not in doc root". this problem was hard to solve, because AWstats lied in /usr/local/awstats/ and the document root for my server was /srv/www/vhosts.

the solution is to delete the entries AWstats makes in the /etc/apache2/httpd.conf and create symbolic links in your virtual hosts httpdocs and httpsdocs-folder to the AWstats-directories needed. then in your vhost.conf and vhost_ssl.conf you have to make entries to the symbolic links. this did the job for us.

details:

installing AWstats:

  • attention! all the following steps must be done as root.
  • download AWstats at http://awstats.sourceforge.net and save the archive in /usr/local/.
  • unpack and delete the archive. the asterix can be replaced with the version-number.
    gzip -d awstats*.tgz
    tar -xf awstats*.tar
    rm awstats*.tar
    mv awstats* awstats
    cd awstats/tools/
  • create the folders /etc/awstats and var/lib/awstats
    mkdir /etc/awstats
    mkdir /var/lib/awstats
  • in the folder /usr/local/awstats/tools/ is a perl script called awstats_configure.pl. run this and follow the questions.
    perl awstats_configure.pl
  • in the Apache-configuration-folder, usually /etc/httpd/ or /etc/apache2/ check the file httpd.conf for entries that AWstats made. in the Apache-configuration check for an entry CustomLog with a value of combined. if all this is present, everything went fine.
  • change to /usr/local/awstats/wwwroot/cgi-bin/ and copy awstats.model.conf to /etc/awstats/.
  • change to /etc/awstats/ and rename awstats.model.conf to your desired virtual hosts name. then copy this file and create symbolic for every virtual host on your server. attention! the subdomain www also needs a separate file. to understand the way AWstats works: everytime the AWstats-scripts are invoked by HTTP, the scripts take the configuration file for the hostname that has been accessed.
    mv awstats.model.conf awstats.foo.com.conf
    ln -s awstats.foo.com.conf awstats.www.foo.com.conf
    cp awstats.foo.com.conf awstats.foo2.com.conf
    ln -s awstats.foo2.com.conf awstats.www.foo2.com.conf
    ln -s awstats.foo2.com.conf awstats.webmail.foo2.com.conf
    cp awstats.foo2.com.conf awstats.foo3.com.conf
    ln -s awstats.foo3.com.conf awstats.www.foo3.com.conf
    ...
  • now every not symbolic linked configuration-file has to edited.
  • first setup the LogFile-directive. here you have to point to the virtual hosts access-logs. it is a little bit tricky if you want to use several logfiles, like you want if you use SSL. for these cases AWstats has some program in /usr/local/awstats/tools/ called logresolvemerge.pl. this program combines logfiles. example:
    LogFile="/var/log/access.log"
    LogFile="/usr/local/awstats/tools/logresolvemerge.pl /var/log/access.log /var/log/access_ssl.log |"
    LogFile="/usr/local/awstats/tools/logresolvemerge.pl /var/log/access*.log |"
  • fill the SiteDomain-directive with you virtual hosts name and add all the subdomains and the IP in the HostAliases-directive. example:
    SiteDomain="foo.com"
    HostAliases="foo.com www.foo.com webmail.foo.com bar.foo.com 66.66.66.66"
  • now all the logfiles have to be processed by AWstats. in /usr/local/awstats/tools/ there is a program called awstats_updateall.pl. this processes all the configuration-files and all included logfiles. example:
    perl /usr/local/awstats/tools/awstats_updateall.pl
    now
  • to automatically run this script you must make a crontab-entry. for daily running:
    crontab -e
    i
    0 * * * * /usr/bin/perl /usr/local/awstats/tools/awstats_updateall.pl now
    :w
    :x
    for hourly running:
    crontab -e
    i
    0 */12 * * * /usr/bin/perl /usr/local/awstats/tools/awstats_updateall.pl now
    :w
    :x
  • now you can run AWstats in your browser by typing: http://foo.com/awstats/awstats.pl
installing Geo::IP:
  • download the GeoIP C library and the Perl-Module Geo::IP. additionally make sure that zlib-devel is installed on your system.
  • first compile the C library:
    gzip -d GeoIP*.tar.gz
    tar -xf GeoIP*.tar
    rm GeoIP*.tar
    cd GeoIP*
    ./configure --prefix=/usr --exec-prefix=/usr
    make
    make install
    cd ..
    rm -R GeoIP*
  • then compile the Perl-module:
    gzip -d Geo-IP*.tar.gz
    tar -xf Geo-IP*.tar
    rm Geo-IP*.tar
    cd Geo-IP*
    perl Makefile.PL LIBS='-L/usr/lib' INC='-I/usr/include'
    make
    make install
    cd ..
    rm -R Geo-IP*
  • in all your AWstats configuration-files in /etc/awstats/ you have to uncomment this line:
    LoadPlugin="geoip GEOIP_STANDARD /usr/share/GeoIP/GeoIP.dat"
fixing the suexec problem:
  • delete the entries AWstats makes in the /etc/apache2/httpd.conf.
  • assuming that you have no interest in compiling your apache completely new, the workaround starts with making symbolic links in every virtual hosts httpdocs- and if you use SSL also in your httpsdocs-folder:
    cd /srv/www/vhosts/foo.com/httpdocs
    ln -sd /usr/local/awstats/wwwroot/classes/awstatsclasses
    ln -sd /usr/local/awstats/wwwroot/css/ awstatscss
    ln -sd /usr/local/awstats/wwwroot/icon/awstatsicons
    ln -sd /usr/local/awstats/wwwroot/cgi-bin awstats
    cd /srv/www/vhosts/foo.com/httpsdocs
    ln -sd /usr/local/awstats/wwwroot/classes/awstatsclasses
    ln -sd /usr/local/awstats/wwwroot/css/ awstatscss
    ln -sd /usr/local/awstats/wwwroot/icon/awstatsicons
    ln -sd /usr/local/awstats/wwwroot/cgi-bin awstats
  • now in your vhost.conf and vhost_ssl.conf make the following entries:
    vhost.conf:
    ScriptAlias /awstats/ "/srv/www/vhosts/foo.com/httpdocs/awstats/"
    <Directory "/srv/www/vhosts/foo.com/httpdocs/awstats/">
            Options none
            AllowOverride None
            Order allow,deny
            Allow from all
    </Directory>
    vhost_ssl.conf:
    ScriptAlias /awstats/ "/srv/www/vhosts/foo.com/httpsdocs/awstats/"
    <Directory "/srv/www/vhosts/foo.com/httpsdocs/awstats/">
            Options none
            AllowOverride None
            Order allow,deny
            Allow from all
    </Directory>
  • now run the Plesk update script:
    /usr/local/psa/admin/sbin/websrvmng -a -v
  • restart Apache2:
    /etc/init.d/apache2 restart
  • now you can run AWstats in your browser by typing: http://foo.com/awstats/awstats.pl

Sunday, 04. March 2007 • trackback url

Re: AWstats, Plesk 8 and suexec

you are great! what can i say :)

Reply

Thursday, 15. November 2007 • fan • @wwwReply

trackback url

Re: AWstats, Plesk 8 and suexec

Awesome!

Why is my awstats folder not pwd protected?

Anyway -> how can I make it so!

~ David

Reply

Saturday, 05. April 2008 • David • • • Reply

trackback url

Re: AWstats, Plesk 8 and suexec

Nevermind! Got it.

Great guide, couldn't have done without it.

~ David

Reply

Sunday, 06. April 2008 • David • • • Reply

trackback url

Add Comment

( to reply to a comment, click the reply link next to the comment )

Comment Title:
Your Name:
Email Address:
Make Public?
Website:
Make Public?

Comment:


Allowed XHTML tags : a, b, i, strong, code, acrynom, blockquote, abbr. Linebreaks will be converted automatically.


Captcha:

captcha image

Soundfile:


please type the content of the above image or the soundfile into the following form-field: