ispCP - Board - Support
[HowTo] AwStats Static Pages - Printable Version

+- ispCP - Board - Support (http://www.isp-control.net/forum)
+-- Forum: ispCP Omega Contributions Area (/forum-40.html)
+--- Forum: Howtos (/forum-41.html)
+--- Thread: [HowTo] AwStats Static Pages (/thread-295.html)

Pages: 1 2 3 4 5 6


[HowTo] AwStats Static Pages - SniperSister - 03-30-2007 06:48 PM

Hi @all,

During the last days I tried to integrate the static pages, which can be generated by awstats. The following HowTo is not finished at all, because the generated stats aren't protected by a passwort or something. I'm currently thinking about howto realize this protection. On top of that, I wasn't able to test it on other distris than Debian Etch and ispCP Omega RC2

First of all, install awstats:
Code:
apt-get install awstats

To get static pages, you'll first have to enable Omega's ability to generate awstats configuration files for each domain. Open your ispcp configuration file (should be in /etc/ispcp/) and search the following line:
Code:
AWSTATS_DIR = no

Replace the "no" with the place where the awstats configuration file should be stored, for example /etc/awstats:
Code:
AWSTATS_DIR = /etc/awstats

When you add a new domain, Omega will generate a awstats-configuration file now. In the next step, we need to create a cronjob for each domain. Omega provides a function to create cronjobs, but this function is disabled at the moment, so we need to enable it. Open /var/www/ispcp/engine/ispcp-dmn-mngr and search for these lines (should be around 3540):

Code:
return $rs if ($rs != 0);

    $rs = dmn_add_mta_data($dmn_data);

Below at the following lines:

Code:
# Modified by Snipersister for awstats Support
    $rs = dmn_add_crontab_data($dmn_data);

    return $rs if ($rs != 0);

Around line 3640 are the following lines:

Code:
$rs = dmn_del_mta_data($dmn_data);

    return $rs if ($rs != 0);

Again, add the following code below:

Code:
# Modified by Snipersister for awstats Support    
     $rs = dmn_del_crontab_data($dmn_data);

    return $rs if ($rs != 0);

We need to create a directory for each domain, where the stats can be stored, so lets add some lines behind (should be around 1798)

Code:
$rs = make_dir(
                    "$starter_dir/$dmn_name/php5",
                    $sys_user,
                    $sys_group,
                    0750
                    );

    return $rs if ($rs != 0);
    }

Add the following lines behind this code, so it looks like this:

Code:
$rs = make_dir(
                    "$starter_dir/$dmn_name/php5",
                    $sys_user,
                    $sys_group,
                    0750
                    );

    return $rs if ($rs != 0);
    }

    # Added by SniperSister
    #
    # AwStats Directory
    #

    $rs = make_dir(            
                    "$www_dir/$dmn_name/statistics",
                    $sys_user,
                    $sys_group,
                    0755
                    );
    return $rs if ($rs != 0);

Okay, now Omega will generate a crontab file for each domain - but with the wrong cronjob! We'll have to change this by editing the template file /etc/ispcp/crontab/parts/dmn_bk_entry.tpl
In the template you'll find a backup cronjob which isn't used anymore. So we'll replace him with our awstats cronjob:
Code:
{MINUTE} {HOUR}  * * *   perl /var/www/ispcp/engine/awstats/awstats_buildstaticpages.pl -config={DMN_NAME} -update -lang=en -awstatsprog=/usr/lib/cgi-bin/awstats.pl -dir=/var/www/virtual/{DMN_NAME}/statistics/

Finally we'll have to edit the apache templates, so each user can view his stats:

At first, edit /etc/ispcp/apache/httpd.conf and remove this line:
Code:
Alias /stats "/usr/lib/cgi-bin/awstats/"

Afterwards, edit /etc/ispcp/apache/parts/ispcp_base.tpl and remove this line again (why doubly?!):
Code:
Alias /stats "/usr/lib/cgi-bin/awstats/"

Now open /etc/ispcp/apache/parts/dmn_entry.tpl and replace
Code:
Redirect /stats http://{DMN_NAME}/awstats/awstats.pl
with
Code:
Alias /stats    {WWW_DIR}/{DMN_NAME}/statistics/


Below
Code:
# httpd dmn entry cgi support END.

you'll have to add:
Code:
<Directory "{WWW_DIR}/{DMN_NAME}/statistics">
        AllowOverride None
        DirectoryIndex awstats.{DMN_NAME}.html
        Order allow,deny
        Allow from all
    </Directory>

The next step is to link the awstats staticpages script into the right directory:
Code:
ln -s  /var/www/ispcp/engine/awstats /usr/share/doc/awstats/examples

and copying the icons which are shown:
Code:
mkdir /var/www/awstats
ln -s /var/www/awstats/icon /usr/share/awstats/icon

The last step is to create a database directory for awstats:
Code:
mkdir /var/cache/awstats

Now you're finished! Add a new domain, wait a 24 Hours until the stats have been generated and open them with http://www.domainname.com/stats/

Best Regards
Snipy


RE: [HowTo] AwStats Static Pages - BioALIEN - 03-30-2007 07:31 PM

Brilliant, thanks for this how to. I'll be trying it out on Ubuntu Smile


RE: [HowTo] AwStats Static Pages - BeNe - 03-31-2007 01:38 AM

Great HowTo Snipy Wink
Thanks!

I will test it under Debian Etch!


RE: [HowTo] AwStats Static Pages - SniperSister - 04-01-2007 02:42 AM

@Dev-Team
Couldn't this be interesting for the stable release?


RE: [HowTo] AwStats Static Pages - xister - 04-01-2007 03:14 AM

Have a look at the roadmap:
http://www.isp-control.net/ispcp/query?status=new&status=assigned&status=reopened&milestone=VHCS+%CF%89+1.0.0+-+RC2


RE: [HowTo] AwStats Static Pages - SniperSister - 04-01-2007 03:59 AM

xister Wrote:Have a look at the roadmap:
http://www.isp-control.net/ispcp/query?status=new&status=assigned&status=reopened&milestone=VHCS+%CF%89+1.0.0+-+RC2

Yeah i know that it's planed to integrate AwStats but as far as i know it's planed to use the perl script to generate the pages on the fly. So i asked wheather the integration of static pages wouldn't be better...


RE: [HowTo] AwStats Static Pages - RatS - 04-01-2007 07:51 AM

why is it better?


RE: [HowTo] AwStats Static Pages - SniperSister - 04-01-2007 05:24 PM

RatS Wrote:why is it better?

- Each user can only view his own statistics. The perl script makes it possible that you can take a look at the stats of other domains, hosted on this server (using ?config=domainname.tld )
- Security holes in the perl script aren't this dangerous (cause' you can't directly access the script)
- You don't get problems with suexec (which was my problem while trying to get the perl script running on all domains)


RE: [HowTo] AwStats Static Pages - BioALIEN - 04-02-2007 08:29 AM

+1, I know a few ISPs who use statics for this reason also.


RE: [HowTo] AwStats Static Pages - xyladecor - 04-11-2007 06:25 PM

hmmmm.... but: what happens to the statistics of the last month? i can't look at them anymore, right?
next problem: my hoster (no, not a garage-hoster) deactivated it, because it produces a lot of server load to generate the static pages.