ISPconfig 3 - awstats

Discussion in 'Tips/Tricks/Mods' started by Mouton, Mar 29, 2009.

  1. BorderAmigos

    BorderAmigos New Member

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

    astewart ISPConfig Developer ISPConfig Developer

    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:
    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?
     
    Last edited: Feb 2, 2010
  3. BorderAmigos

    BorderAmigos New Member

    My mistake, sorry. After coffee I see /etc/apache2/conf.d/awstats.conf is
    Code:
    <Directory "/usr/share/awstats">
            Options None
            AllowOverride all
            Order allow,deny
            Allow from all
    </Directory>  
    
    Looking back at your suexec.log
    Code:
    [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
    Code:
    chown -R web2:client0 /var/clients/client0/web2/cgi-bin
    
     
    Last edited: Feb 2, 2010
  4. astewart

    astewart ISPConfig Developer ISPConfig Developer

    I've done this a few days ago:

    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.

    :(
     
  5. BorderAmigos

    BorderAmigos New Member

    Does the cgi-bin directory have the same permissions, owner and group as the file?
     
  6. astewart

    astewart ISPConfig Developer ISPConfig Developer

    It does:

    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.
     
  7. BorderAmigos

    BorderAmigos New Member

    Sorry, I'm out of ideas then.
     
  8. astewart

    astewart ISPConfig Developer ISPConfig Developer

    Yeah, no matter what I've tried I keep getting the same damb error:

    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:
    I'm wondering if I should be executing the 'awstats.pl' from /var/www
    ...
     
    Last edited: Feb 2, 2010
  9. BorderAmigos

    BorderAmigos New Member

    I show the exact same suexec info as you and am running it from the cgi-bin directory and it is working.
    Code:
    [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.
    Code:
    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.
     
    Last edited: Feb 2, 2010
  10. astewart

    astewart ISPConfig Developer ISPConfig Developer

    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?
     
  11. astewart

    astewart ISPConfig Developer ISPConfig Developer

    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:
    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 ?
     
  12. admins

    admins Member

    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
     
  13. BorderAmigos

    BorderAmigos New Member

    For me it is working with Debian 5 (5.04) and ISPConfig 3.0.1.6.
     
  14. admins

    admins Member

    could you pls make a short howto?

    thanks
    admins
     
  15. BorderAmigos

    BorderAmigos New Member

    Pretty much just followed what is in this thread. Had some issues with directory permissions.
     
  16. admins

    admins Member

    could you post this premission issues?

    thanks
    admins
     
  17. BorderAmigos

    BorderAmigos New Member

    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...
    Code:
    apt-get install awstats
    chmod 755 /var/lib/awstats
    
    Copy awstats.pl to cgi-bin directory
    Code:
    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
    Code:
    <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
    Code:
    <?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([email protected]_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
    Code:
    //** 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
    Code:
    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
    Code:
    /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.
     
    Last edited: Mar 26, 2010
  18. dclardy

    dclardy Member

    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.
     
  19. BorderAmigos

    BorderAmigos New Member

    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.
     
  20. dclardy

    dclardy Member

    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.
     

Share This Page