December 9, 2009

Awstats in Plesk

It took me some time, but I managed to configure Plesk with Awstats and now I tought that it would have been good to share my results. Trying to have awstats working with Plesk is not too easy - it took me a few hours. And in fact is not that integrated... Anyway, that's how I've done it. The most important point is having the directory layout that Plesk expects. That, at least in my case, was not the one that I had with my normal RPM installation on Centos. Here are the steps to solve the problem(s). You will have to create symbolic links to the files. Plesk is expecting to find: /var/www/cgi-bin/awstats (in my system I had /var/www/awstats) /var/share/awstats/ with the awstats *.pl files (in my system they were in /usr/bin) /usr/local/psa/etc/awstats/awstats.domainname-http.conf (in my system the configuration files were in /etc/awstats and had a different name pattern) Use: rpm -ql awstats to find where your awstats has installed the files. After doing that, to test if you are going in the right direction, try to run: /usr/bin/awstats_updateall.pl now -confdir="/usr/local/psa/etc" -awstatsprog="/var/www/awstats/awstats.pl" (use your awstats.pl path) If it works, then run the Plesk program that generates statistics, to make sure that everything is fine: /usr/local/psa/admin/sbin/statistics Debug as needed in this step... Sidenote: the awstats configuration files are not updated (apparently) when you update the domain aliases. If you update your domain aliases you will have to update them in the configuration file by hand. If you have domains that you do not manage with Plesk in your server (I do have some of them, for non profit organisations), you can mimic the plesk scripts with a couple of scripts. First, you need to have the log file processing enabled in your crontab. I'm using this slightly modified version of the script included with awstats (it's in /etc/cron.daily/00awstats in my system): #!/bin/bash if [ -f /var/log/httpd/access_log ] ; then exec /usr/bin/awstats_updateall.pl now -configdir="/etc/awstats" -awstatsprog="/var/www/awstats/awstats.pl" >/dev/null fi if [ -f /var/log/httpd/access_log ] ; then exec /usr/bin/awstats_updateall.pl now -configdir="/usr/local/psa/etc/awstats" -awstatsprog="/var/www/awstats/awstats.pl" >/dev/null fi exit 0 And then you need a script to create the reports that are not processed by Plesk (apparently Plesk is processing just the domains that are managed by Plesk itself - which makes sense). This one (adapt the domains) is what I'm using: #!/bin/bash domains_to_process=("baravalle.it" "phpgrabcomics.org" "server.phpgrabcomics.org" "verdibiellesi.it") len=${#domains_to_process[@]} i=0 while [ $i -lt $len ]; do awstats_buildstaticpages.pl -config=${domains_to_process[$i]}-http --configdir="/usr/local/psa/etc/awstats" -lang=it -dir=/home/httpd/vhosts/${domains_to_process[$i]}/statistics/webstat -awstatsprog=/var/www/awstats/awstats.pl let i++ done You will have to insert it in your crontab (it needs to be the crontab of a user that has write access to the directories where you are saving you reports).

Add system swap space for virtual memory paging:

Swap space may be a swap partition, a swap file or a combination of the two. One should size swap space to be at least twice the size of the computer's RAM. (but less than 2GB)
1. dd if=/dev/zero of=/swapfile bs=1024 count=265032 - Create file filled with zeros of size 256Mb
2. mkswap /swapfile - Create swap file
3. swapon /swapfile - Begin use of given swap file. Assign a priority with the "-p" flag.
4. swapon -s - List swap files
5. cat /proc/swaps - Same as above