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/awstatsmkdir /etc/awstats
mkdir /var/lib/awstats - in the folder
/usr/local/awstats/tools/is a perl script calledawstats_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 filehttpd.conffor entries that AWstats made. in the Apache-configuration check for an entryCustomLogwith a value ofcombined. if all this is present, everything went fine. - change to
/usr/local/awstats/wwwroot/cgi-bin/and copyawstats.model.confto/etc/awstats/. - change to
/etc/awstats/and renameawstats.model.confto 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/calledlogresolvemerge.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 theHostAliases-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 calledawstats_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
for hourly running:
i
0 * * * * /usr/bin/perl /usr/local/awstats/tools/awstats_updateall.pl now
:w
:xcrontab -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
- download the GeoIP C library and the Perl-Module Geo::IP. additionally make sure that
zlib-develis 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"
- 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 yourhttpsdocs-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.confandvhost_ssl.confmake the following entries:
vhost.conf:
vhost_ssl.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>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

