To administer your WestHost account, please enter your
Domain Name or Server Manager Username.

WestHost: Professional Website Hosting Company








Results 1 to 6 of 6
  1. #1

    Default AWStats on secondary domains

    Lately I've noticed that the blog post on this is out of date so here is a more up to date version.

    Step 1:
    First we must change the apache configuration file. If you look at the very bottom of /etc/httpd/conf/httpd.conf (note you may have VirtualHost *:80 within the < and > tags, whatever you have make sure just to copy it)
    Code:
    <VirtualHost *>
    ServerName secondarydomain.com
    ServerAlias www.secondarydomain.com
    DocumentRoot /var/www/secondarydomain
    </VirtualHost>
    We are going to add a single line to this file. We need to tell Apache that we want a custom log for this domain. We will want to have the new logs written to the same directory as they would be by default, we would just want to write them to a new file name, maybe something like secondarydomain_access_log.

    Code:
    <VirtualHost *>
    ServerName secondaryDomain.com
    ServerAlias www.secondaryDomain.com
    DocumentRoot /var/www/secondarydomain
    CustomLog logs/secondaryddomain_access_log combined
    </VirtualHost>

    Step 2:
    We will need to restart the account. We can do so via the
    Code:
    /etc/init.d/httpd restart
    command from SSH or by using the "Restart Account" link on the left in Site Manager.

    Step 3:
    Once we've done this, we're ready to setup AWStats to start gathering stats from this new log. In the /etc/awstats directory you will see either awstats.conf or awstats.primarydomain.conf, lets make a copy of this file and name it awstats.secondarydomain.conf, replacing secondarydomain with your domain name of course. After this file has been copied, we need to make a change to it. Open the file up in your favorite file editor and look for a line that looks like this:
    Code:
    LogFile="/usr/local/awstats/tools/logresolvemerge.pl /var/log/httpd/access_log /var/log/httpd/ssl_access_log |"
    This line might also look like:
    Code:
    LogFile="/var/log/httpd/access_log"
    We will need to change this line to look like this:
    Code:
    LogFile="/var/log/httpd/secondaryddomain_access_log"
    Just replace "secondaryddomain_access_log" with what you put after log/ in Step 1 above.

    Next line we want to look for is
    Code:
    SiteDomain="primaryDomain.com"
    and
    Code:
    HostAliases="primaryDomain.com www.primaryDomain.com 127.0.0.1 localhost"
    we simply want to change anywhere it says "primaryDomain.com" with your secondary domain. So in our example we will want to change these lines to look like:
    Code:
    SiteDomain="secondaryDomain.com"
    and
    Code:
    HostAliases="secondaryDomain.com www.secondaryDomain.com 127.0.0.1 localhost"
    There is one more optional change you can make, I like to make this change but it is not nessessary. If you look for this line:
    Code:
    AllowToUpdateStatsFromBrowser=0
    and change it to read:
    Code:
    AllowToUpdateStatsFromBrowser=1
    This will enable an "Update Now" link within AWStats so you can have it update the stats instantly. NOTE: you must have the server parse the stats at least once before this link will work. Just use this command to parse the stats:
    Code:
    /usr/local/awstats/tools/awstats_updateall.pl now
    Step 4: (NOTE: You only need to do this if you have not done this before)
    We need to tell the server that it should parse the new information automatically. To do this we want to edit the file located at /bin/web_logs.sh . Once you bring it up you may see something like this:
    Code:
    for i in `ls /var/www/cgi-bin/plugins/Webalizers 2>/dev/null`
    do
        cd /var/www/cgi-bin/plugins/Webalizers/${i}
        /var/www/cgi-bin/plugins/Webalizers/${i}/webalizer.cgi  2>&1 >/dev/null
    done
    
    exit 0
    /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=primaryDomain
    or something like this:
    Code:
    /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=primaryDomain
    If your log looks like the first one, you MUST remove the "exit 0" line out of here. If you do not, your stats will not be calculated properly. What we want to do is replace the line that looks like
    Code:
    /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=primaryDomain
    with this:
    Code:
    /usr/local/awstats/tools/awstats_updateall.pl now
    What this does is change AWStats so it will scan the /etc/awstats folder and parse and calculate all of the stats instead of just the single domain.

    Step 4b: (optional, but recommended, you also don't have to do this more than once)
    By default, the only time statistics are generated is when the log file gets above 1MB in size. We can have the server automatically parse the stats every night, even if the log doesn't get that big. All we need to do is SSH into the account, execute the following command:
    Code:
    editcron -e
    and find the line that looks like this:
    Code:
    58 1 * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=primarydomain
    NOTE: the first two numbers, in my case 58 and 1 may change, I would recommend you leave these numbers the same. You would want to change the part in this line that looks like this:
    Code:
    /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=primarydomain
    to read:
    Code:
    /usr/local/awstats/tools/awstats_updateall.pl now
    so in my example it would read:
    Code:
    58 1 * * * /usr/local/awstats/tools/awstats_updateall.pl now
    Once you've changed the line you can do control-x, hit the y key and then hit enter.

    Step 5:
    You're done! It is all setup! To access the stats you would go to http://primarydomain.com/awstats/awstats.pl?config=secondarydomainwhere secondary domain is the part in the .conf file between the awstats. and the .conf. So if I had awstats.mydomain.conf I would access it via http://primarydomain.com/awstats/awstats.pl?config=mydomain

    Please note that this is not supported by WestHost Technical Support, if you have troubles you can post here so that we in the forums can help you
    Last edited by dattas; 09-25-2009 at 12:01 PM.
    Unofficial technical support for the world.

  2. #2
    Junior Member
    Join Date
    Dec 2009
    Posts
    5

    Default Sub Domain Stats Not Seen

    Thank you for the very informative and clear information on setting up aw stats for a sub domain. I believe I did everything right but when I go to check out the stats it seems that it is not seeing the sub domain still. I have updated and Restarted My Account but it still is not picking up the stats. Any suggestions would be appreciated.

  3. #3
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,685

    Default

    Check to see if the second log is being written first.
    Code:
    CustomLog logs/secondaryddomain_access_log combined
    Go to /var/log/httpd and see if the file secondaryddomain_access_log is there. Your actual file name may be different depending on what you entered. logs is actually a symbolic link to /var/log/httpd directory.

    The other thing is this:
    NOTE: you must have the server parse the stats at least once before this link will work. Just use this command to parse the stats:
    Code:
    /usr/local/awstats/tools/awstats_updateall.pl now
    Did you do that?
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

  4. #4
    Junior Member
    Join Date
    Dec 2009
    Posts
    5

    Default

    I did check the access_log and it is there but I did not do the command. I am quite the novice so just to confirm so I don't ruin my account settings. I go into the file manager and click on "Execute a Command" and then type in "/usr/local/awstats/tools/awstats_updateall.pl now" and hit submit?

  5. #5
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,685

    Default

    I normally use Putty to establish an SSH session to run such commands but you can try it in the File Manager.
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

  6. #6
    Junior Member
    Join Date
    Dec 2009
    Posts
    5

    Default Problem Resolved

    Thank you for your input and yes I could do the command /usr/local/awstats/tools/awstats_updateall.pl now via File Manager. It actually was another issue (a spelling issue in the code). Thanks.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •