PDA

View Full Version : ISPconfig 3 - awstats


Mouton
29th March 2009, 23:16
I quickly wrote this small plugin to create awstats config file automatically (base on the ISPconfig 2 plugin)
It really needs improvement and automation but that's a start for whoever has time to write more about it...
Do not hesitate to improve or fix it....

PS: congrats for the 3.0.1 version !


Just paste the following code in a awstats_plugin.inc.php file in the plugins-available directory.



<?php

class awstats_plugin {

var $plugin_name = 'awstats_plugin';
var $class_name = 'awstats_plugin';

//* This function is called during ispconfig installation to determine
// if a symlink shall be created for this plugin.
function onInstall() {
global $conf;

if(@$conf['services']['awstats'] == true) {
return true;
} else {
return false;
}

}


/*
This function is called when the plugin is loaded
*/

function onLoad() {
global $app;

/*
Register for the events
*/

//* Mail Domains
$app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'domain_insert');
$app->plugins->registerEvent('web_domain_update',$this->plugin_name,'domain_update');
$app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'domain_delete');
}


function user_insert($event_name,$data) {
// TODO: handle users for awstats access
}

function user_update($event_name,$data) {
// TODO: handle users for awstats access
}

function user_delete($event_name,$data) {
// TODO: handle users for awstats access
}

function domain_update($event_name,$data) {
global $app, $conf;

$this->domain_insert($event_name, $data);
}

function domain_insert($event_name,$data) {
global $app, $conf;

if(!@is_file("/etc/awstats/awstats.".$data["new"]["domain"].".conf") || ($data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"])) {
if ( @is_file("/etc/awstats/awstats.".$data["old"]["domain"].".conf") )
exec("rm -f /etc/awstats/awstats.".$data["old"]["domain"].".conf");

exec( "echo 'Include \"/etc/awstats/awstats.conf\"' > /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
exec( "echo 'LogFile=\"/var/log/ispconfig/httpd/".$data["new"]["domain"]."/access.log\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
exec( "echo 'SiteDomain=\"".$data["new"]["domain"]."\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf");
// exec( "echo 'AllowAccessFromWebToFollowingAuthenticatedUsers=\"".$ht_user_list."\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf");
}

}

function domain_delete($event_name,$data) {
global $app, $conf;

if($data["old"]["domain"] != '' ) {
if ( @is_file("/etc/awstats/awstats.".$data["old"]["domain"].".conf") )
exec("rm -f /etc/awstats/awstats.".$data["old"]["domain"].".conf");
}
}




} // end class
?>

andypl
1st April 2009, 15:19
Ok i put this scripts in the plugins folder and how its works ?
I dont see any options on ISPConfig panel for awstats.

till
4th April 2009, 09:43
To enable the script you will have to create a symlink in the plugins-enabled folder to the plugin in the plugins-available folder like it is done for the other plugins. Afterwards you edit the file /usr/local/ispconfig/server/lib/config.inc.php and add the line:

$conf['services']['awstats'] = true;

Then the plugin should work. The author of the plugin may correct me if I missed an additional step as I did not tested the plugin yet. An of xourse the awstats package from your linux distribution has to be installed.

Mouton
5th April 2009, 22:42
Indeed, you'll need to install awstats first. Sadly, I do not have to to make any tutorial yet. I'll try but.

This plugin is only - for the moment -for generating awstats config for each ISPconfig 3 domain.

I'll work on the user htaccess restriction as soon as possible.

archerjd
7th April 2009, 06:46
I'll work on the user htaccess restriction as soon as possible.

Hi Mounton,
It seems to me that the .htaccess file even though has been used for decades , is a little messy. Would mod-auth-mysql be a cleaner/better solution?

One thing we have to keep in mind is if a user account gets disabled for some oddball reason. The .htaccess file will have to be modified and then again when the account is re-enabled. I believe if my memory serves me right, mod-auth-mysql has a variable just for things like that and it gives you the ability to use the same user accounts within the dbispconfig database.

There are some conns to this. mod-auth-mysql requires basic authentication (plain text).
Also, you would have to add something like this to the vhost.conf.master file.
<tmpl_if name='awstats' op='==' value='y'
<Directory <tmpl_var name='web_document_root_www'>/stats
AuthBasicAuthoritative Off
AuthUserFile /dev/null
AuthMySQL On
AuthName "AWstats Service"
AuthType Basic
Auth_MySQL_Host localhost
Auth_MySQL_User ispconfig
Auth_MySQL_Password <tmpl_var name='db_password'>
AuthMySQL_DB dbispconfig
AuthMySQL_Password_Table ftp_user
Auth_MySQL_Username_Field username
Auth_MySQL_Password_Field password
Auth_MySQL_Group_Table ftp_user
Auth_MySQL_Group_Field gid
Auth_MySQL_Encryption_Types Crypt
Auth_MySQL_Empty_Passwords Off
Auth_MySQL_Authoritative On
Auth_MySQL_Password_Clause " AND enabled=1"
require group <tmpl_var name='system_group'>
</Directory>
</tmpl_if>

Mouton
7th April 2009, 16:01
Good idea.

I'm not sure, but mod-auth-mysql seems to have recent security issues as well as compatibility problems with apache 2.2 (not tested).
Maybe would it be better not to use a third party module but the mod_authn_dbd (http://httpd.apache.org/docs/2.2/mod/) module ?

till
7th April 2009, 16:06
ISPConfig 3 uses already .htacess protection for the webalizer statistics and that is based on plain old text files for compatibility reasons and I dont see a reason to add an additional external package as requirement if it is not nescessary and if it does not bring any real benefit as ispconfig has to write all the apache config and the sattistics config as files anyway, so writing a few lines into another file do not matter.

astewart
7th April 2009, 21:38
I installed AWSTATS and created the plugin.
Then created a Symlink to enable the plugin.
After this I added '$conf['services']['awstats'] = true;' to the config.inc.php

I have refreshed the Sites in ISPCONFIG which created the 'awstats.demo.com.conf' but it doesn't appears to be creating any awstats folder in the Clients web folder. Nor do I see any apache config file for awstats.

Am I missing something here?

archerjd
7th April 2009, 23:24
Thanks Till, I stand corrected. :)
Does ISPConfig 3 re-use the existing accounts created for the site for creating the .htaccess file?

archerjd
7th April 2009, 23:47
Good idea.

I'm not sure, but mod-auth-mysql seems to have recent security issues as well as compatibility problems with apache 2.2 (not tested).
Maybe would it be better not to use a third party module but the mod_authn_dbd (http://httpd.apache.org/docs/2.2/mod/) module ?

Mounton,
I believe I found an article describing what you have mentioned above but it seems to be a little out dated. Do you have a link describing this as of this year?
I have been using the pre-packaged version in Debian Lenny for testing some applications and do not want to continue using it if there are still issues with it.

till
8th April 2009, 11:29
Thanks Till, I stand corrected. :)
Does ISPConfig 3 re-use the existing accounts created for the site for creating the .htaccess file?

There is a password input field for the statistics password in the site setting.

Thomas Jensen
14th April 2009, 09:00
Which username to use in the statistics?

falko
15th April 2009, 13:28
Try admin.

andypl
16th April 2009, 14:41
Ok I have a setup for each page in AWStats directory.
As now set up in cron to check all config and update data?
By default, AWStats displays http://domain.ltd/cgi-bin/awstats.pl but i want http://domain.ltd/stats

archerjd
17th April 2009, 05:49
I have looked into this once before and it seemed to me that mod-rewrite can do this beautifully. ;)

letezo
18th April 2009, 23:14
I've just installed the plugin. It creates the awstats config files for the domains, but it is far from working in its current state. Things need to do:


Cron task to update the statistics for each domain. The default cron script installed by the system uses only the awstats.conf file and hardwired to build stats from /var/log/apache/access.log only, so that is clearly not enough in our case.

Support for running awstats.pl without generally enabling CGI support for those domains. It can be protected by the same password as the Webalizer statistics. We have to provide a separate path for awstats. There should be a link from the Webalizer statistics to jump to awstats to help users.

New option for the Stats tab of the site in ISPConfig to enable/disable awstats for the domain.

Testing this on all the supported platforms.

letezo
18th April 2009, 23:51
I suggest moving the domain specific configuration files into a new directory like /etc/awstats/ispconfig or somewhere else. This directory should be created by the awstats plugin on installation or first use.

The Ubuntu 8.04 LTS distribution contains a script:
/usr/share/doc/awstats/awstats_updateall.pl

It can be configured (see the beginning of this file) to update the statistics for all the ISPConfig managed domains then.

Related topic, both for Webalizer and AWStats: We can enable GeoIP for them if we install the geoip-bin package and take care of downloading the free GeoIP Country database from MaxMind. I haven't tested this yet, however.

letezo
18th April 2009, 23:59
We have to place those config files directly under /etc/awstats, unfortunately. AWStats tries to load the config files for the virtual hosts from there.

letezo
19th April 2009, 00:19
We have to avoid the following bug on Ubuntu 8.04 LTS:
http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg385558.html

Due to the above bug awstats.conf.local cannot be included from awstats.conf, since that would be a "nested" (three level deep) include. We can comment out the Include "/etc/awstats/awstats.conf.local" line at the end of awstats.conf and include that from each domain specific awstats config file. Or we can change awstats.conf directly, but that would be bad practice and might be nor so resilent to upgrades as we would want.

vogelor
20th April 2009, 22:18
Things need to do:


Cron task to update the statistics for each domain. The default cron script installed by the system uses only the awstats.conf file and hardwired to build stats from /var/log/apache/access.log only, so that is clearly not enough in our case.



i don't know if anybody is working on awstats support, but IF!

if you name the plugin xxx_core_module.inc.php and then create the link in the plugins-core dir instead of the plugins-enabled dir (is done automatically by the installer if the plugin is called xxx_core_module.inc.php), then the plugin is loaded and executed every minute. so you do not neet any cron taks! (have a look at the monitor_core_module i wrote some times ago. with this module i have had the same problem with the cron - job and till and i decided to implement it this way instead of creating a special cron-job for every module needed such...

grungy
10th May 2009, 19:03
awstats_updateall.pl on Debain is run as following:

/usr/share/doc/awstats/examples/awstats_updateall.pl now -awstatsprog=/usr/lib/cgi-bin/awstats.pl

The awstats conf file should be more rich, for example:

exec( "echo 'Include \"/etc/awstats/awstats.conf\"' > /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
exec( "echo 'LogFile=\"/var/log/ispconfig/httpd/".$data["new"]["domain"]."/access.log\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
exec( "echo 'SiteDomain=\"".$data["new"]["domain"]."\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf");
exec( "echo 'DNSLookup=\"1\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
exec( "echo 'DirData =\"/var/cache/awstats\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
exec( "echo 'AllowFullYearView=\"3\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf" );

admins
18th May 2009, 14:16
To the simlink: From where to where must I create a symlink ln -s ....

Thanks
admins

djtremors
25th May 2009, 10:55
Oo this looks to be a good plugin hack. Might add my bit to take logins from mysql and create a .htaccess htpasswd file as i'm migrating my ispc2 accounts to my ispc3 server.

long live the plugins!

Is there a list what hooks are available for plugins? I have a DR design in mind and would like to use this opportunity to mirror when accounts are created and deleted with rsync ability etc.etc.

till
25th May 2009, 11:14
There is no list yet. But if you look into the files in mods-available, you can easily find the definitions. Currently these are available:

client_insert, client_update, client_delete
database_insert, database_update, database_delete
mail_domain_insert, mail_domain_update, mail_domain_delete
mail_user_insert, mail_user_update, mail_user_delete
mail_access_insert, mail_access_update, mail_access_delete
mail_forwarding_insert, mail_forwarding_update, mail_forwarding_delete
mail_transport_insert, mail_transport_update, mail_transport_delete
mail_get_insert, mail_get_update, mail_get_delete
mail_content_filter_insert, mail_content_filter_update, mail_content_filter_delete
server_insert, server_update, server_delete
server_ip_insert, server_ip_update, server_ip_delete
firewall_insert, firewall_update, firewall_delete
software_update_inst_insert, software_update_inst_update, software_update_inst_delete
web_domain_insert, web_domain_update, web_domain_delete
ftp_user_insert, ftp_user_update, ftp_user_delete
shell_user_insert, shell_user_update, shell_user_delete

The event names correspond with the database table names.

BorderAmigos
28th May 2009, 02:45
I did all of the above and still not working. I'll read it thru 5 or 10 more times to find what I'm missing.

djtremors
28th May 2009, 10:28
@BorderAmigos : What does "still not working" mean. Did you make a vhost for it

I had to change mine to work with debians apt-get version which was different.


if(!@is_file("/etc/awstats/awstats.".$data["new"]["domain"].".conf") || ($data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"])) {
if ( @is_file("/etc/awstats/awstats.".$data["old"]["domain"].".conf") )
exec("rm -f /etc/awstats/awstats.".$data["old"]["domain"].".conf");

exec( "echo 'Include \"/etc/awstats/awstats.conf\"' > /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
exec( "echo 'LogFile=\"/var/log/ispconfig/httpd/".$data["new"]["domain"]."/access.log\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
exec( "echo 'SiteDomain=\"".$data["new"]["domain"]."\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf");
// exec( "echo 'AllowAccessFromWebToFollowingAuthenticatedUsers=\"".$ht_user_list."\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf");
}


my /etc/apache2/conf.d/awstats.conf looks like this (for now).
Alias /awstatsclasses "/usr/share/awstats/classes/"
Alias /awstatscss "/usr/share/awstats/css/"
Alias /awstats-icon "/usr/share/awstats/icon/"
ScriptAlias /stats/ "/usr/lib/cgi-bin/"
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/share/awstats">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>

what I did notice is that this only supports the domain and not the www. autodomains which I'll get around to adding along with authentication (been sick lately any contenders to SQL to get list, be my guest)...

djtremors
29th May 2009, 12:52
Ok, got around to making a quick patch to allow my awstats to appear using the configuration method mentioned earlier and using a redirection from /stats to redirect to /ispcstats with the domain.

This will create a .htaccess_stats file with the clients login/password from the database. Change as you please if you want email users to be able to use it instead etc. There is no super admin login atm but that's an easy addition by adding a admin:{hash} to the write routine.

There may be other little tweaks needs in regards to getting awstats part working but this is only the ispc3 side.

Code :
Ok, got around to making a quick patch to allow my awstats to appear using the configuration method mentioned earlier and using a redirection from /stats to redirect to /ispcstats with the domain.

This will create a .htaccess_stats file with the clients login/password from the database. Change as you please if you want email users to be able to use it instead etc. There is no super admin login atm but that's an easy addition by adding a admin:{hash} to the write routine.

There may be other little tweaks needs in regards to getting awstats part working but this is only the ispc3 side.

Code :
[PHP]<?php

class awstats_plugin {

var $plugin_name = 'awstats_plugin';
var $class_name = 'awstats_plugin';

//* This function is called during ispconfig installation to determine
// if a symlink shall be created for this plugin.
function onInstall() {
global $conf;

if(@$conf['services']['awstats'] == true) {
return true;
} else {
return false;
}

}


/*
This function is called when the plugin is loaded
*/

function onLoad() {
global $app;

/*
Register for the events
*/

//* Mail Domains
$app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'domain_insert');
$app->plugins->registerEvent('web_domain_update',$this->plugin_name,'domain_update');
$app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'domain_delete');
$app->plugins->registerEvent('client_insert',$this->plugin_name,'client_insert');
$app->plugins->registerEvent('client_update',$this->plugin_name,'client_update');
$app->plugins->registerEvent('client_delete',$this->plugin_name,'client_delete');
}

function awstats_update($event_name,$data) {
global $app, $conf;
$result = $app->db->queryAllRecords("SELECT * FROM web_domain wd,sys_group sg,client c where wd.sys_groupid = sg.groupid and sg.client_id = c.client_id");
$fp = fopen($domroot."/.htpasswd_stats","w");
if ($fp)
{
foreach($result as $row)
{
$domain = $row['domain'];
$username = $row['username'];
$password = $row['password'];
$domroot = $row['document_root'];
echo "Domain::$domain DomRoot::$domroot\n";

fwrite($fp,$username.":".$password."\n");
}
fclose($fp);
}
$fp = fopen($domroot."/web/stats/.htaccess","w");
if ($fp)
{
$access='AuthType Basic
AuthName "Site Client Access Only"
AuthUserFile '.$domroot.'/.htpasswd_stats
<limit GET PUT POST>
require valid-user
</limit>
Redirect 301 /stats http://www.'.$domain.'/ispcstats/awstats.pl?config=www.'.$domain.'
';

fwrite($fp,$access);
fclose($fp);
}
}

function client_insert($event_name,$data) {
global $app, $conf;
$this->awstats_update();
}

function client_update($event_name,$data) {
global $app, $conf;
$this->awstats_update();
}

function client_delete($event_name,$data) {
global $app, $conf;
$this->awstats_update();
}

function user_insert($event_name,$data) {
// TODO: handle users for awstats access
}

function user_update($event_name,$data) {
// TODO: handle users for awstats access
}

function user_delete($event_name,$data) {
// TODO: handle users for awstats access
}

function domain_update($event_name,$data) {
global $app, $conf;

$this->domain_insert($event_name, $data);
}

function domain_insert($event_name,$data) {
global $app, $conf;

if(!@is_file("/etc/awstats/awstats.".$data["new"]["domain"].".conf") || ($data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"])) {
if ( @is_file("/etc/awstats/awstats.".$data["old"]["domain"].".conf") )
exec("rm -f /etc/awstats/awstats.".$data["old"]["domain"].".conf");

exec( "echo 'Include \"/etc/awstats/awstats.conf\"' > /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
exec( "echo 'LogFile=\"/var/log/ispconfig/httpd/".$data["new"]["domain"]."/access.log\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
exec( "echo 'SiteDomain=\"".$data["new"]["domain"]."\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf");
// exec( "echo 'AllowAccessFromWebToFollowingAuthenticatedUsers=\"".$ht_user_list."\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf");

}

}

function domain_delete($event_name,$data) {
global $app, $conf;

if($data["old"]["domain"] != '' ) {
if ( @is_file("/etc/awstats/awstats.".$data["old"]["domain"].".conf") )
exec("rm -f /etc/awstats/awstats.".$data["old"]["domain"].".conf");
}
}




} // end class
?>

sirrus
23rd November 2009, 11:13
Thank you for this plugin.

It is not creating awstat conf files in my case. A lot of people use secured php where exec is denied. I think it is at least one securtiy rights issue.

I suggest to rewrite this code to use fwrite:

function domain_insert($event_name,$data) {
global $app, $conf;

$newfile = "/etc/awstats/awstats.".$data["new"]["domain"].".conf";
$oldfile = "/etc/awstats/awstats.".$data["old"]["domain"].".conf";

if(!@is_file($newfile) || ($oldfile != '' && $newfile != $oldfile)) {
if ( @is_file($oldfile) )
exec("rm -f ".$oldfile);

$fp = fopen($newfile,"w");
if ($fp) {
$awcon = "Include \"/etc/awstats/awstats.conf\"\n" .
"LogFile=\"/var/log/ispconfig/httpd/".$data["new"]["domain"]."/access.log\"\n" .
"SiteDomain=\"".$data["new"]["domain"]."\"\n" .
"DNSLookup=\"1\"\n" .
"DirData =\"/var/cache/awstats\"\n" .
"AllowFullYearView=\"3\"";
//$awcon .= "\nAllowAccessFromWebToFollowingAuthenticatedUsers= \"".$ht_user_list."\"";
fwrite($fp, $awcon);
fclose($fp);
}
}
}

korbynn
16th January 2010, 06:46
I am running on CentOS 4.3.

I did all that was suggested in the last 2 posts (Thankyou) but awstats is still not processing the website stats or are the stats else where.
My client really likes awstats as opposed to webalizer.

I noticed that the /etc/awstats/awstats.conf did not exist so I
cp awstats.model.conf awstats.conf
hoping that this would make the config for awstats to work.

Any thoughts or pointers to other info is appreciated.
:confused:

stefanr
27th January 2010, 17:28
Hello,

i have tried the following things

1.)
aptitute install awstats

2.)
vim /usr/local/ispconfig/server/plugins-available/awstats_plugin.inc.php and write the code from post #27 and post #28 into the file.

3.)
ln -s /usr/local/ispconfig/server/plugins-available/awstats_plugin.inc.php /usr/local/ispconfig/server/plugins-enabled/awstats_plugin.inc.php

4.)
vim /usr/local/ispconfig/server/lib/config.inc.php and insert the row $conf['services']['awstats'] = true;

i think this is all what i must do on the ispconfig server. And now at all domains the www.domain.de/stats should be replaced by the awstats files and i must see it under www.domain.de/stats.

It doesent works at the moment have anyone a idea?

kind regards
Stefan

BorderAmigos
27th January 2010, 17:43
It is working on my setup. For me it does not replace the webalizer stats in /stats but gives me additional in /awstats. Both packages are working.

Pretty much as above except create directory in the web root called awstats and give it permissions 777.

stefanr
27th January 2010, 17:58
Hello BorderAmigos,

thanks for your answer, you mean that it is all done and everything is fine.
But i have no directory awstats in any domain. I create in one of the domains manually and chmod 777 the awstats. Now should the awstats plugin should work.

Can i do manually an awstats update?

kind regards

STEFAN

BorderAmigos
27th January 2010, 18:11
Check to see that the config's were created (one for each site)...

/etc/awstats/awstats.example.com.conf

I use a cron job that runs the below, again for every site...

/usr/lib/cgi-bin/awstats.pl -update -config=example.com -output=main > /var/www/example.com/web/awstats/index.html

There may have been other tweaks I don't remember at the moment.

stefanr
27th January 2010, 18:23
Hi,

thanks i've done and now i got this error

Error: SiteDomain parameter not defined in your config/domain file. You must edit it for using this version of AWStats.

Setup ('/etc/awstats/awstats.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).

when i go to domain.de/awstats

cat /etc/awstats/awstats.domain.de.conf
Include "/etc/awstats/awstats.conf"
LogFile="/var/log/ispconfig/httpd/domain.de/access.log"
SiteDomain="domain.de"

shoud i give the webserver read//write rights to the awstats.conf file?

what do i wrong?

kind regards
STEFAN

BorderAmigos
27th January 2010, 18:38
All I can do is say what my settings are.

All of the conf files in /etc/awstats are owned by root and permissions of 644.

In /etc/awstats/awstats.conf
SiteDomain=""

in /etc/awstats/awstats.example.com.conf
SiteDomain="example.com"

astewart
1st February 2010, 21:02
So I have awstats installed and no problems creating static 'index.html' file in the following path for each domain:
/var/www/mydomain.net/web/awstats/

I have a seperate cron setup for each domain as follows:
0 1 * * * /usr/lib/cgi-bin/awstats.pl -update -config=mydomain1.com -output=main > /var/www/mydomain1.com/web/awstats/index.html
0 1 * * * /usr/lib/cgi-bin/awstats.pl -update -config=mydomain2.net -output=main > /var/www/mydomain2.net/web/awstats/index.html

I copied the 'awstats.pl' file to each 'cgi-bin' directory for each domain that has 'cgi' enabled.
Chmodded the script to 755 and changed the user and group to to the owner of that domain, eg (web2:client0).

So there are no problems viewing the static page but anytime I click on one of the links from the main awstats page to see 'Full List' or any link for that matter that directly calls the 'awstats.pl', I get the 'Internal 500' error because of 'suexec'.
When I disabale 'suexec' it works fine but I don't want to have to disable it.

Obviously it has something to due with the settings in the 'awstats.conf' file, at least I think so.

Here is what the suexec.log shows:
[2010-02-01 14:29:42]: uid: (5004/web2) gid: (5004/5004) cmd: .php-fcgi-starter
[2010-02-01 15:17:01]: uid: (5004/web2) gid: (5004/5004) cmd: awstats.pl
[2010-02-01 15:17:01]: command not in docroot (/var/clients/client0/web2/cgi-bin/awstats.pl)

Here is my awstats.conf file:
Alias /awstatsclasses "/usr/share/awstats/classes/"
Alias /awstatscss "/usr/share/awstats/css/"
Alias /awstats-icon "/usr/share/awstats/icon/"
ScriptAlias /stats/ "/usr/lib/cgi-bin/"
ScriptAlias /cgi-bin/ "/usr/lib/cgi-bin/"
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/share/awstats">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>

And here is what is listed in one of my specified .vhost files for a domain: (Just the CGI Part)
# cgi enabled
<Directory /var/clients/client0/web2/cgi-bin>
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /var/clients/client0/web2/cgi-bin/
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
# suexec enabled
SuexecUserGroup web2 client0
# php as fast-cgi enabled
<Directory /var/www/mydomain.net/web>
AddHandler fcgid-script .php .php3 .php4 .php5
FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php
Options +ExecCGI
AllowOverride all
Order allow,deny
Allow from all
</Directory>

I've already done a lot of google searching but no luck.
Does anyone have any ideas why this is not working with 'suexec' enabled?

Thanks!

BorderAmigos
1st February 2010, 22:01
Not sure but check and make sure the directories involved have the correct owners, groups and permissions as well as the files. This messed me up at one point.

astewart
2nd February 2010, 13:41
Not sure but check and make sure the directories involved have the correct owners, groups and permissions as well as the files. This messed me up at one point.

I've been playing around with permissions and user/groups for the last 3 -4 days but no luck.

It has to be with the way I have the directive setup, but I think I tried everything (Well obviously not everything)


BorderAmigos, would you be able to show me what you have in your
/etc/apache2/conf.d/awstats.conf file?

BorderAmigos
2nd February 2010, 16:53
"BorderAmigos, would you be able to show me what you have in your
/etc/apache2/conf.d/awstats.conf file? "

I don't have this file in this location. It is not part of the Apache configuration. Under /etc/awstats there are awstats.conf and another awstats.example.com.conf for each domain and subdomain (24 files in my case).

Here is an example of one of the domain files...

Include "/etc/awstats/awstats.conf"
LogFile="/var/log/ispconfig/httpd/chloetry.com/access.log"
SiteDomain="chloetry.com"
HostAliases="www.chloetry.com localhost 127.0.0.1"


The awstats.conf is to big to post so I attached it.

PS The "Include awstats.local.conf" file included at the end is just a copy of the "awstats.conf" file without the include. It's there in case an update overwrites the original file.

astewart
2nd February 2010, 17:02
"BorderAmigos, would you be able to show me what you have in your
/etc/apache2/conf.d/awstats.conf file? "

I don't have this file in this location. It is not part of the Apache configuration. Under /etc/awstats there are awstats.conf and another awstats.example.com.conf for each domain and subdomain (24 files in my case).

Here is an example of one of the domain files...

Include "/etc/awstats/awstats.conf"
LogFile="/var/log/ispconfig/httpd/chloetry.com/access.log"
SiteDomain="chloetry.com"
HostAliases="www.chloetry.com localhost 127.0.0.1"


The awstats.conf is to big to post so I attached it.

PS The "Include awstats.local.conf" file included at the end is just a copy of the "awstats.conf" file without the include. It's there in case an update overwrites the original file.

This is what i currently have in my '/etc/apache2/conf.d/awstats.conf '
Alias /awstatsclasses "/usr/share/awstats/classes/"
Alias /awstatscss "/usr/share/awstats/css/"
Alias /awstats-icon "/usr/share/awstats/icon/"
ScriptAlias /stats/ "/usr/lib/cgi-bin/"
ScriptAlias /cgi-bin/ "/usr/lib/cgi-bin/"
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/share/awstats">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Here is an example of one of my domain files:
Include "/etc/awstats/awstats.conf"
LogFile="/var/log/ispconfig/httpd/mydomain.net/access.log"
SiteDomain="mydomain.net"

I noticed that you attached the awstats.conf file from /etc/awstats, I was wondering what you have in your awstats.conf file in /etc/apache2/conf.d directory?

BorderAmigos
2nd February 2010, 17:36
As I say in the start of the previous post, /etc/apache2/conf.d does not contain any awstats.conf files.

astewart
2nd February 2010, 18:11
As I say in the start of the previous post, /etc/apache2/conf.d does not contain any awstats.conf files.

Sorry about that, I mis-read your previous post.

So your telling me that you do not have an apache2 config file for awstats?
How are you able to get the icons loading then without that?

You must have an apache Config file somewhere for awstats, with directives and script aliases setup don't you?

So from Post #26:
http://www.howtoforge.com/forums/showpost.php?p=190809&postcount=26

Where do you have this setup:
Alias /awstatsclasses "/usr/share/awstats/classes/"
Alias /awstatscss "/usr/share/awstats/css/"
Alias /awstats-icon "/usr/share/awstats/icon/"
ScriptAlias /stats/ "/usr/lib/cgi-bin/"
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/share/awstats">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>

If you don't have it setup, I'm unsure how you have awstats configured.

Have your tried clicking on the links in the main AWSTATS page, like when you want to vire the 'Full List' for Top Counties or Hosts?

BorderAmigos
2nd February 2010, 18:35
My mistake, sorry. After coffee I see /etc/apache2/conf.d/awstats.conf is

<Directory "/usr/share/awstats">
Options None
AllowOverride all
Order allow,deny
Allow from all
</Directory>


Looking back at your suexec.log

[2010-02-01 14:29:42]: uid: (5004/web2) gid: (5004/5004) cmd: .php-fcgi-starter
[2010-02-01 15:17:01]: uid: (5004/web2) gid: (5004/5004) cmd: awstats.pl
[2010-02-01 15:17:01]: command not in docroot (/var/clients/client0/web2/cgi-bin/awstats.pl)

This is saying the file awstats.pl is not in the docroot. Also, the permissions look a bit off, gid: (5004/5004) should be maybe 5004/client0 ?

Make sure the awstats.pl file is in /var/clients/client0/web2/cgi-bin/ then try

chown -R web2:client0 /var/clients/client0/web2/cgi-bin

astewart
2nd February 2010, 18:46
I've done this a few days ago:
root@myServer: cd /var/clients/client0/web2/cgi-bin
root@myServer:/var/clients/client0/web2/cgi-bin# ls -al
total 552
drwxr-x--x 2 web2 client0 4096 2010-01-28 08:31 .
drwxr-xr-x 9 root root 4096 2010-01-31 00:13 ..
-rwxr-xr-x 1 web2 client0 548956 2010-01-28 08:31 awstats.pl


Thats why I'm confused why 'suexec' is still giving me the same Error.
Both the 'cgi-bin' directory and the 'awstats.pl' file have permissions set to 755. Also tried 777 but no luck.

:(

BorderAmigos
2nd February 2010, 18:51
Does the cgi-bin directory have the same permissions, owner and group as the file?

astewart
2nd February 2010, 18:55
Does the cgi-bin directory have the same permissions, owner and group as the file?

It does:

root@Server:/var/clients/client0/web2# ls -al
total 48
drwxr-xr-x 9 root root 4096 2010-01-31 00:13 .
drwxr-xr-x 6 root root 4096 2010-01-28 16:40 ..
drwxr-x--x 2 web2 client0 4096 2010-01-28 08:31 cgi-bin
drwxr-xr-x 4 web2 client0 4096 2008-11-11 22:29 home
-rw-rw-r-- 1 root root 40 2009-11-27 08:42 .htpasswd_stats
lrwxrwxrwx 1 web2 client0 39 2008-12-08 16:06 log -> /var/log/ispconfig/httpd/mydomain.net
drwxrwxrwx 2 web2 client0 12288 2009-10-21 16:01 tmp
drwxr-xr-x 23 web2 client0 4096 2010-01-29 11:03 web
root@Server:/var/clients/client0/web2#

Just to verifiy it isn't a problem with this one domain, I also tried thisa with a few of my other domains but I get the same results.

BorderAmigos
2nd February 2010, 19:02
Sorry, I'm out of ideas then.

astewart
2nd February 2010, 21:02
Yeah, no matter what I've tried I keep getting the same damb error:

[2010-02-02 15:51:16]: uid: (5004/web2) gid: (5004/5004) cmd: awstats.pl
[2010-02-02 15:51:16]: command not in docroot (/var/clients/client0/web2/cgi-bin/awstats.pl)

I'm starting to wonder if 'suexec' is working properly. Once I disable it for that specific site, I have no problems following the internal awstat links (Full List, etc)

suexec info:
root@myServer:/etc/apache2/conf.d# /usr/lib/apache2/suexec -V
-D AP_DOC_ROOT="/var/www"
-D AP_GID_MIN=100
-D AP_HTTPD_USER="www-data"
-D AP_LOG_EXEC="/var/log/apache2/suexec.log"
-D AP_SAFE_PATH="/usr/local/bin:/usr/bin:/bin"
-D AP_UID_MIN=100
-D AP_USERDIR_SUFFIX="public_html"

I'm wondering if I should be executing the 'awstats.pl' from /var/www
...

BorderAmigos
2nd February 2010, 21:32
I show the exact same suexec info as you and am running it from the cgi-bin directory and it is working.

[2010-02-02 15:51:16]: uid: (5004/web2) gid: (5004/5004) cmd: awstats.pl

The (5004/5004) here still looks wrong to me. Something somewhere has the wrong uid/gid. Here is a script that sets up user/groups for a domain in mine. Not sure if it will help you.

chown -R web1:client1 /var/www/clients/client1/web1/*
chown -R web1:client1 /var/www/clients/client1/web1/.*
chown root:root /var/www/clients/client1/web1/
chown -R root:root /var/www/clients/client1/web1/bin
chown -R root:root /var/www/clients/client1/web1/dev
chown -R root:root /var/www/clients/client1/web1/etc
chown -R root:root /var/www/clients/client1/web1/lib
chown -R root:root /var/www/clients/client1/web1/usr
chown -R web1:client1 /var/www/clients/client1/web1/cgi-bin

Some have to be root for the chroot jail to work.
I think suexec is more picky about UID and GID than permissions.

astewart
3rd February 2010, 13:58
Thanks for trying to help BorderAmigos, Unfortunately I've checked the uid/gid over a million times and everything is as it should be.

It might be a bug in the version of Ubuntu or something (8.04), or something else conflicting with suexec.

:(

Anyone else have any other ideas?

astewart
3rd February 2010, 15:55
I think I may have found the answer but I'm afriad I will 'break' everything.

I noticed with any new install of 'ispconfig 3' the Clients directory is located in /var/www/clients

I have an older setup but running the latest version of ispconfig 3 and the path of my Clients folder is in /var/clients... Meaning this is NOT in the 'suexec' DocRoot.

The DocRoot for suexec as mentioned above is /var/www/

And the error in the suexec log shows:
command not in docroot (/var/clients/client0/web2/cgi-bin/awstats.pl)

So my question is, if I actually do a Move (mv) of the clients folder from /var to /var/www, what will I be breaking besides the .vhost files and such?

What is the best way to solve this, Move the clients folder or recompile suexec to change the DocRoot to /var ?

admins
16th February 2010, 22:41
Does it work with debian 5 and ispconfig 3.0.1.6?
If someone has this config and it works, pls post a full howto.
Now this thread takes posts about 6sites. I mean thats useful for all,
thanks

admins

BorderAmigos
16th February 2010, 22:49
For me it is working with Debian 5 (5.04) and ISPConfig 3.0.1.6.

admins
16th February 2010, 23:34
could you pls make a short howto?

thanks
admins

BorderAmigos
16th February 2010, 23:37
Pretty much just followed what is in this thread. Had some issues with directory permissions.

admins
16th February 2010, 23:51
could you post this premission issues?

thanks
admins

BorderAmigos
22nd February 2010, 20:07
I think my permissions issue was that /var/lib/awstats was created with 750 and needed 755.

My attempt at a howto from what is working on my server. The locations may differ on non-Debian systems.

Install awstats and fix permission...

apt-get install awstats
chmod 755 /var/lib/awstats


Copy awstats.pl to cgi-bin directory

cp /usr/lib/cgi-bin/awstats.pl /var/www/clients/client1/web1/cgi-bin/awstats.pl
chown web1:client1 /var/www/clients/client1/web1/cgi-bin/awstats.pl


put awstats.conf in /etc/apache2/conf.d

<Directory "/usr/share/awstats">
Options None
AllowOverride all
Order allow,deny
Allow from all
</Directory>


Put the plugin in /usr/local/ispconfig/server/plugins-available/awstats_plugin.inc.php

<?php
class awstats_plugin {
var $plugin_name = 'awstats_plugin';
var $class_name = 'awstats_plugin';
//* This function is called during ispconfig installation to determine
// if a symlink shall be created for this plugin.
function onInstall() {
global $conf;
if(@$conf['services']['awstats'] == true) {
return true;
} else {
return false;
}
}
/* This function is called when the plugin is loaded */
function onLoad() {
global $app;
/*
Register for the events
*/
//* Mail Domains
$app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'domain_insert');
$app->plugins->registerEvent('web_domain_update',$this->plugin_name,'domain_update');
$app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'domain_delete');
}
function user_insert($event_name,$data) {
// TODO: handle users for awstats access
}
function user_update($event_name,$data) {
// TODO: handle users for awstats access
}
function user_delete($event_name,$data) {
// TODO: handle users for awstats access
}
function domain_update($event_name,$data) {
global $app, $conf;
$this->domain_insert($event_name, $data);
}
function domain_insert($event_name,$data) {
global $app, $conf;

if(!@is_file("/etc/awstats/awstats.".$data["new"]["domain"].".conf") || ($data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"]))
{
if ( @is_file("/etc/awstats/awstats.".$data["old"]["domain"].".conf") )
exec("rm -f /etc/awstats/awstats.".$data["old"]["domain"].".conf");
exec( "echo 'Include \"/etc/awstats/awstats.conf\"' > /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
exec( "echo 'LogFile=\"/var/log/ispconfig/httpd/".$data["new"]["domain"]."/access.log\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
exec( "echo 'SiteDomain=\"".$data["new"]["domain"]."\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf");
exec( "echo 'HostAliases=\"www".$data["new"]["domain"]." localhost 127.0.0.1\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf");
}

}
function domain_delete($event_name,$data) {
global $app, $conf;
if($data["old"]["domain"] != '' ) {
if ( @is_file("/etc/awstats/awstats.".$data["old"]["domain"].".conf") )
exec("rm -f /etc/awstats/awstats.".$data["old"]["domain"].".conf");
}
}
} // end class
?>


Add this at the end of file /usr/local/ispconfig/server/lib/config.inc.php

//** AWStats Mod
$conf['services']['awstats'];

?>


After refreshing the ISPConfig 3 sites, there should be a conf file for each site in /etc/awstats/ ...
awstats.example.com.conf

Include "/etc/awstats/awstats.conf"
LogFile="/var/log/ispconfig/httpd/example.com/access.log"
SiteDomain="example.com"
HostAliases="www.example.com localhost 127.0.0.1"


Create an directory for each site in web/awstats/ and copy the .htaccess from /web/stats/ to it. This will cause it to use the same password as the stats directory for access.

And finally I added a cron job for each site

/usr/lib/cgi-bin/awstats.pl -update -config=example.com -output=main > /var/www/example.com/web/awstats/index.html

The cron job is run as root. I set it up using Webmin, I'm not sure if cron jobs set up with ISPConfig3 will run as root or not.

I did not put this in 'core' as someone suggests as that would have it run every minute which is excessive. I'm only running it once an hour.

I'm not sure if all of the above is needed, maybe some redundancy. But it is working for me in Debian Lenny. If I forgot something I'll add it when remembered. Good luck.

EDIT: Just remembered something. AWStats sets up a default, non-site specific, cron job when installed to run every 10 minutes. I disabled this as it doesn't seem needed.

ANOTHER EDIT: You may need to put a symlink in plugins-enabled to the plugin in plugins available. Also, copy awstats.pl to each sites cgi-bin directory to access historical data (previous months, years, et cetera). Make sure it is executable.

dclardy
24th February 2010, 16:57
After refreshing the ISPConfig 3 sites, there should be a conf file for each site in /etc/awstats/ ...
awstats.example.com.conf

Include "/etc/awstats/awstats.conf"
LogFile="/var/log/ispconfig/httpd/example.com/access.log"
SiteDomain="example.com"
HostAliases="www.example.com localhost 127.0.0.1"


Create an directory for each site in web/awstats/ and copy the .htaccess from /web/stats/ to it. This will cause it to use the same password as the stats directory for access.

And finally I added a cron job for each site

/usr/lib/cgi-bin/awstats.pl -update -config=example.com -output=main > /var/www/example.com/web/awstats/index.html

The cron job is run as root. I set it up using Webmin, I'm not sure if cron jobs set up with ISPConfig3 will run as root or not.

I did not put this in 'core' as someone suggests as that would have it run every minute which is excessive. I'm only running it once an hour.

I'm not sure if all of the above is needed, maybe some redundancy. But it is working for me in Debian Lenny. If I forgot something I'll add it when remembered. Good luck.

EDIT: Just remembered something. AWStats sets up a default, non-site specific, cron job when installed to run every 10 minutes. I disabled this as it doesn't seem needed.

Just wondering what you mean by refreshing the sites. I have changed something in them. Then set it back, and I checked the folder, but I see nothing. What am I missing?

Thanks.

BorderAmigos
24th February 2010, 17:03
It should have created the conf files in /etc/awstats/ for each domain, it did on mine. Even created files for subdomains which I erased and manually put in as aliases.

It all else fails, you can manually create the conf files by copying the above code and changing the domain name where appropriate.

dclardy
24th February 2010, 17:05
I would rather not have to do that, but I guess that I can. It is weird how it works on one and not the other.

Is there anyway to tell if ISPConfig is seeing the plugin? Maybe I did not paste that in correctly?

Thanks.

dclardy
8th March 2010, 20:16
Is there anyway to see if ISPCOnfig 3 has recognized the plug-in?

till
8th March 2010, 20:28
Enable debuggging in ispconfig (see ispconfig faq for details).

dclardy
9th March 2010, 04:15
I was looking around in the plugins-available and plugins-enabled folders. The awstats plugin was placed in the plugins-available folder by me.

Does ISPConfig use it if that is the case? If not, how do I enable it? Is it done through the interface or do I just copy the file to the other folder?

Thanks.

dclardy
9th March 2010, 04:24
@BorderAmigos:

In your tutorial, you forgot to mention that you have to place the plugin in the plugins-enabled folder. Adding that to the folder solved the problem.

Thanks.

till
9th March 2010, 08:16
Do not put the plugin in the plugins-enabled folder or it might get removed on the next update. Plugins have to be in the plugins-available folder and then create a symlink in the plugins-enabled folder to the plugin in the plugins-available folder.

paxpacis
26th March 2010, 15:04
Hi,

first of al thanks.. I needed awstats on my ispconfig3 server.. :)

How did you solve the /awstats-icon/ 'problem' al the images are not shown on my awstats page. Did you changed the apache config or did you add something per site?

p.s. maybe you can team-up with DJ Tremors, I use his version of awstats on my ispconfig2 servers.

http://www.djtremors.com/index.php?option=com_content&task=view&id=25&Itemid=139

astewart
26th March 2010, 16:55
Correct, you should have a 'awstats.conf' file that contains the following:
Alias /awstatsclasses "/usr/share/awstats/classes/"
Alias /awstatscss "/usr/share/awstats/css/"
Alias /awstats-icon "/usr/share/awstats/icon/"
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/share/awstats">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>

On my setup (Ubuntu), I have the awstats.conf file located in:
/etc/apache2/conf.d

And make sure your 'apache2.conf' has this included at the end of the file:
Include /etc/apache2/conf.d/

Keeping this in mind, like I said, this is how I have it setup on my Ubuntu Server and the location of where awstats is installed.

djtremors
26th March 2010, 22:42
Hey all, I'm subscribed to this thread and am in the middle (almost done) of working on an awstats mod similar to that of the ispc2 version.

It works by browsing /stats which authenticates you and takes you to a /ispcstats/awstats.pl?config=www.{domain}.tld page and ensures you cannot access any other config other than the ones you own.

It creates/updates/delete based on client and site changes, it can be told to update all or single entries so if you want to forcibly update all users and all domains rather than just the one you added/edited/deleted then it will do so.

It's been taking a while as I've written it one way only to find I can optimize it more and more and more and keep rewriting it..LOL...

I've also been avoiding using exec() and whatever else I've seen in the past which caused some grief to some people but need volunteers on stuff like suPHP etc as I don't use it but happy to write a flexible plugin to manage different configurations.

PM me on the type of configuration you would need and any info that may help me from running into trouble as I have little time on my hands.

George (Dj Tremors).

paxpacis
27th March 2010, 01:00
Hi

Correct, you should have a 'awstats.conf' file that contains the following:

I had this one but it did not contain your additions.

I ended up with this config as yours disable ALL my other sites ;)

Alias /awstatsclasses "/usr/share/awstats/classes/"
Alias /awstatscss "/usr/share/awstats/css/"
Alias /awstats-icon "/usr/share/awstats/icon/"
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/share/awstats">
Options None
AllowOverride All
Order allow,deny
Allow from all
</Directory>

Thanks again, this helped me, I have no icons.. the classes and css do not seem to make a difference..

djtremors
27th March 2010, 13:18
OK, I finally got a workable plugin made up. not the best as I problems with certain ideas and had to scrap the code for it and then redo it again etc.

Anyone one to try it out, not tested with suphp or suexec which i'm sure the /ispcstats path will not work for it but happy to make changes for those would want a solution.

http://www.emperor-it.com/component/content/section/5.html

George

paxpacis
27th March 2010, 23:35
Hi, I will try it out coming week, I use suexec.. let you know how it goes ;)



Anyone one to try it out, not tested with suphp or suexec which i'm sure the /ispcstats path will not work for it but happy to make changes for those would want a solution.

George

wikidd
4th August 2010, 23:28
I followed the instructions on djtremors website to install the Awstats plugin.

But it doesn't seem to work. When I go to domain.tld/stats I get a redirect to domain.tld/jawstats/?config=domain.tld but its a 404 Error.

I installed jawstats according to the website except didn't know if I had to manually add all the site to the config (hoping the awstats script did that somehow like it does for awstats).

I tried to turn off jawstats and go back to just awstats but when I made jawstats = false in the plugin config the redirect was still pointing to the jawstats directory.

Any help getting this to work is greatly appreciated - at minimum I would be happy with awstats running but ideally would like jawstats.

wikidd
4th August 2010, 23:29
I just checked the jawstats config file and it looks like it had been updated with the sites :)

Now to just get the stats working instead of the 404 error

djtremors
8th August 2010, 02:40
I just checked the jawstats config file and it looks like it had been updated with the sites :)

Now to just get the stats working instead of the 404 error

Yes, you need to wait for ISPC to poll for changes before it updates the config files. I'd have to double check what default I placed into this plugin on the site but thought awstats was the default, not jawstats.

Also remember that after installation, you need to wait for the overnight cron to process the web log files before things will start to populate and work properly. You could technically forcefully run the cron to update immediately to see if things work or not and not wait for cron.

warlock
14th September 2010, 12:10
@djtremors :

I followed your install and the plugin works to a point, it has generated teh awstats.conf
When I run the update script it generates the stats files but I can't seem to get to display if I goto www.xxx.com/ispcstats, and I am getting a 404 error

any ideas ?

djtremors
14th September 2010, 13:43
http://www.emperor-it.com/component/content/article/38-ispconfig3/56-ispconfig3-awstats.html

if you check on my page above, it says to place the below snip into /etc/apache2/conf.d/awstats.conf, has this been done and apache reloaded? I haven't tested on every distro so can't guarantee would it work on all but will help on request.

.
.
Alias /awstats-icon/ /usr/share/awstats/icon/
ScriptAlias /ispcstats/ /usr/lib/cgi-bin/

Also, you should be visiting /stats and not directly to /ispcstats unless you know the full url path/config settings.etc.

warlock
14th September 2010, 13:45
Ok now have disabled jawstats as I can't get this to work, I have version 0.7 installed but even after I add statsname => "myformat [MM][YYYY].txt I am still getting an error
The data file being looked for is awstats20109.12volt.co.za.txt in folder :

Anyway, awstats seem to work but I can't login, what's the user and password ?

warlock
15th September 2010, 10:46
http://www.emperor-it.com/component/content/article/38-ispconfig3/56-ispconfig3-awstats.html

Hey djtremors,

your step
6. dit the /etc/awstats/awstats.conf and enabled the setting AllowAccessFromWebToAuthenticatedUsersOnly to 1. This is the protection to stop 1 domain on your host checking the other domains on your system in combination with the per site setting AllowAccessFromWebToFollowingAuthenticatedUsers.

AllowAccessFromWebToAuthenticatedUsersOnly=1

This is not required, else what happens is the user gets prompted for 2 logins, once by ispconfigs setting "admin" and then by yours "client name".

As ispconfig has the option to change or set a password for the stats site, the user will be prompted for this anyway.

I had endless problems trying to find out why I am being asked twice.

This now presents a problem if the users edit the web address ?config=example.co.za to another sites address they will have access to those stats.


if you do turn off

you will also need to comment out
# vi /etc/apache2/conf.d/awstats.conf

AuthType Basic
AuthName "Site Client Access Only"
AuthUserFile /usr/lib/cgi-bin/.htpasswd_stats
<limit GET PUT POST>
require valid-user
</limit>

djtremors
15th October 2010, 13:06
that problem you are now facing is because you removed what you said is not required.. but it is exactly for that reason

/ispcstats is global to all sites, hence all logins are stored in /usr/lib/cgi-bin/.htpasswd_stats for this url.

AllowAccessFromWebToAuthenticatedUsersOnly=1 forced that users MUST be authenticated (fair enough).

AllowAccessFromWebToFollowingAuthenticatedUsers="adminuser1 ispc3admin" this is a website specific config which says which of those users authenticated have access to this websites stats (this stops cross site access).

www.client1website.com/stats is just a wrapper to preauth the site user(s) and then point to www.client1website.com/cgi-bin/awstats.pl?config=www.client1website.com making it easier to type in. User is already authenticated the first time, it should not reauthenticate unless it changes domain.

Check to make sure your ./web/stats/.htaccess file is redirecting to the same website URL

so www.clientsite.com, the file redirect should be

Redirect 301 /stats http://www.clientsite.com/awstats/?config=www.clientsite.com

PS: sorry, not monitoring this thread much.

till
26th October 2010, 16:01
Please be aware that ispconfig 3.0.3 includes awsatst support with static pages in the /stats directory. This plugin and the steps here might interfere with the ispconfig 3.0.3 awstats implemenatation and may not work or might destroy the ispconfoig 3.0.3 awsatst setup. I recommend to not use this plugin on ispconfig sstems that are newer then 3.0.2.2

Xenocide
26th October 2010, 16:16
Hi Till! We meet again! haha :)

Can you explain how one might access these? I've restored all the files that I can back to originals but I can't find any record or documentation about? Cheers

till
26th October 2010, 16:19
Can you explain how one might access these?

You access them like the webalizer stats. A website has either stats created by awstats or by webalizer and both are in the same directory. The stats are created nightly, so if you switch the statsitics for a site, you will have to wait up to 24 hours.

Just make sure that you have awstats installed and the the paths to the awstats scripts under system > server config > web match the paths in your installation.

but I can't find any record or documentation about?

It is described e.g. in the manual.

Xenocide
26th October 2010, 16:44
Gotta be honest, didn't even realise there was a proper manual... I've just bought it. Thankyou very much!! :)

[Edit: and schedualed an upgrade in for my servers tonight... slaves first yeah?]

yoplait
26th October 2010, 23:44
yeah, that's it.

djtremors
28th October 2010, 03:09
This does work on ISPConfig 3.0.3 as it interacts as a plugin when updating domains or clients.

Errors are most times due to files not created (eg .htpasswd_stats, .htaccess, etc) and people attempting to see stats before the plugin has had a chance to create them which the errors can be seen in the error logs of the site and or apache.

Update a user/domain to force the plugin to run at least once before checking the stats and possibly run the cron once to update the awstats data files for some stats info.

Tremors.

TDS
1st November 2010, 16:09
@till:

Can you provide the default ISPConfig AWStats configuration? I had the plugin before and now ISPConfig 3.0.3. I deleted the stuff coming from the plugin without success cos only one visitor is counted per day. If I run the daily cron in the evening all things are counted correctly.

till
1st November 2010, 18:13
The problem has been rported here and will get fixed with the next bugfix release.

http://bugtracker.ispconfig.org/index.php?do=details&task_id=1395

Agent_M
6th January 2011, 12:15
I have version 3.0.3 installed which should of corrected awstats from only building stats from midnight to 12:30 am, but it still appears to be happening with a site, I was having the issue with this site before upgrading, and still seems to be there for this one site.

Anyway I can correct this so it generates the entire days stats?

djtremors
6th January 2011, 12:21
you might need to check when ISPC rotates it's files and when awstats is processing them, it might be rotating which then works only on a small set of logs.

I have a script which can reprocess all of ispconfig logs if you are happy to nuke your awstats dat file and reprocess the lot.
http://www.emperor-it.com/ispconfig3.html?layout=default

Agent_M
6th January 2011, 12:56
you might need to check when ISPC rotates it's files and when awstats is processing them, it might be rotating which then works only on a small set of logs.

at a quick glance, it looks like they are happening pretty much at the same time ( which might explain why the stats vary quite a bit on the sites that do work ), so maybe somedays awstats wins the race, and other days the log rotations win?

But for one site in particular, it looks like its only ever processes that 30mins worth of data.



I have a script which can reprocess all of ispconfig logs if you are happy to nuke your awstats dat file and reprocess the lot.
http://www.emperor-it.com/ispconfig3.html?layout=default

I'm not worried about loosing any of the stats to date, as they either aren't accurate, or don't contain the info I want ( I should also mention this issue >> http://www.howtoforge.com/forums/showthread.php?p=248137#post248137 )

Will this script change the log rotation or awstats times? or just reprocess the data ( sorry, am just a little unclear on what the script does ).

djtremors
6th January 2011, 13:04
I would tend to believe more that the both run but depending on the number of hits (size of log file) more than anything. A bigger log file on the first site will lag the process of the next one.etc.

Awstats it meant to run just before the log was rotated if it was modified as per the instruction I wrote (where you modified the cron php file or replace webalizer bin with a script). Are you running the awstats_updateall.pl perl script doing all websites at once via cron by chance?

Agent_M
6th January 2011, 14:38
however ispc3.0.3 is set up to do it, is how its doing it, I haven't changed or modified anything from default

and thinking about it, I am not so sure about what I said before, If the log files were rotating at about the same time as awstats, then I wouldn't be getting 30 mins worth of data for this site, I would either get 1 or 2 mins worth, or 24 hours 30mins worth, but I am getting 30 mins worth. for this one site, so I'm a little confused now.

What is the best way to confirm when the log files are being rotated? the 2011mmdd-access.log.gz files all have a changed time of 12:31am give or take a minute, which is why I said I thought they were rotating at about the same time as awstats was building the stats.

Agent_M
6th January 2011, 17:43
Actually don't worry about this just yet, Just noticed there is a 3.0.3.2 update available, applied the update about 10 mins before awstats was due to run, and seems it has fixed the issue for me :) Thanks

I'll post back if I'm wrong, but looks good. Although I am still having trouble with this one relating to search terms etc ( http://www.howtoforge.com/forums/showthread.php?p=248137#post248137 )

radim_h
10th January 2011, 16:32
Hello Guys,

I cannot find default template for awstats.
Where is the template file or script creating /etc/awstats/awstats.domain.tld.conf ?
i want to add some directives for each conf file...

OR should i include my own directives for each stats any how?

is the files /etc/awstats/awstats.conf or /etc/awstats/awstats.conf.local reflected when stats are created? it doesnt seems this way for me...

and also: is there global password function as in ISPC2 ??

thanks for any hint

till
10th January 2011, 17:09
The awstats file gets created by the cron_daily.sh script, there is currently no template for it. Might be a goiod idea to add this as template in future.

radim_h
10th January 2011, 17:45
together with global password for system administrator (eg. i want to see customer's stats), i assume there is no function like this

djtremors
11th January 2011, 01:27
Radim_h: not if you use the static page version built into ispc3, the dynamic plugin I wrote does and you modify it in the beginning of the script.

Also as a note, the dynamic plugin version uses the /etc/awstats/awstats.model.conf as a template and does site specific in the domains conf file/

it's all there in the script, have a read.

radim_h
12th January 2011, 08:10
Hope dynamic plugin will work fine, i'm wondering why your dynamic plugin for ISPC2 was never included in default setup...

how that nice theme of yours, everything works fine with it ?

djtremors
12th January 2011, 09:54
Use the dynamic plugin for ispconfig3, it was designed for it. ispc2 works differently but had the same basic concept/function as the way awstats for ispc3 was made (well 3 was based of 2).

yeah that theme will not work as of 3.0.3 (I believe was) due to the new additional "Home" tab at the top. It basically played bad to it I think but I can't remember now, didn't look into it much and might just work off the new default template and tweak it from there and save as a new template again.
I think this is the first of any positive feedback I've had of the theme so thanks, I was kind of trying to pretty it up and make it have more room with a slicker look..etc.etc. hehe
I want to investigate on making it look like Plesk/CPanel but not too sure how well the template will handle that and my css/html ain't the best either.

radim_h
27th January 2011, 10:31
There is version 7.0 of awstats since December
http://awstats.sourceforge.net/
will try to install that dynamic plugin this weekend