Tomcat access logs format isn't exactly what we need. We could also have modified AWStats configuration files, but with the loss of important information. Thus, let's make Tomcat logs compatible with AWStats. Logs are configured in [Tomcat_install]/conf/server.xml
. They might look something like:
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
Host
definition.
We will replace the valve definition with this one:
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="www_mydomain_com_access_log." suffix=".log" pattern="combined" fileDateFormat="dd-MM-yy" resolveHosts="false"/>
Tomcat has disabled by default CGI executions. This is because CGIs do not conform Tomcat security box. But we know exactly what we are going to do, aren't we ?
The only thing you need to do is renaming [Tomcat_install]/server/lib/servlets-cgi.renametojar
to [Tomcat_install]/server/lib/servlets-cgi.jar
. This will enable AWStats Perl scripts to execute on Tomcat server. When it's done, restart Tomcat.
awstats.war
file's web.xml. You might want to look at this file once downloaded.
AWStats is included in awstats.war
file, therefore you will not need to install AWStats by hand.
Deploy awstats.war
file. Will suffice copying this file into [Tomca_install]/webapps
folder, but in case your Tomcat is configured not to auto-deploy war files, unzip it yourself. By default would create an [Tomca_install]/webapps/awstats
folder.
This is the hardest part, did you already take a coffe?
First we will make some assumptions, are these ones:
/awstats
default context. See Install AWStats. www.mydomain.com
. Now, go to [Tomca_install]/webapps/awstats/WEB-INF/cgi-bin
folder. Next instructions make the assumption this is your current working folder.
awstats.model.conf
into awstats.www.mydomain.com.conf
. awstats.www.mydomain.com.conf
. You can use any text editor of your preference. Now, we will change some file default values. You must look for the attributes and change their values as shown below:
LogFile="[TI]/webapps/awstats/WEB-INF/tools/logresolvemerge.pl [TI]/logs/*.log |"
LogType=W
LogFormat=1
LogSeparator=" "
SiteDomain="www.mydomain.com"
DNSLookup=1
DirData="."
DirCgi="/cgi-bin"
DirIcons="/awstats/icon"
[TI]
with full path to Tomcat. And
www.mydomain.com
with your domain name.
Here you have two choices:
AllowToUpdateStatsFromBrowser=1
in awstats.www.mydomain.com.conf
file, see above. This will allow updating from the web browser with: http://www.mydomain.com/awstats/cgi-bin/awstats.pl?config=www.mydomain.com&update=1
. [Tomca_install]/webapps/awstats/WEB-INF/cgi-bin
folder and run perl awstats.pl -config=www.mydomain.com -update
. Type http://www.mydomain.com/awstats/cgi-bin/awstats.pl?config=www.mydomain.com
. That was all.
From the instructions above, everything is valid for creating separated domain statistics, except for one thing:
Inside your awstats.www.mydomain.com.conf
we said:
LogFile="[TI]/webapps/awstats/WEB-INF/tools/logresolvemerge.pl [TI]/logs/*.log |"
This line was gathering the whole set of log files, and this is against having statistics appart for each domain. We should replace this line to match the log files for the corresponding domain, as we said when changing Tomcat access logs format:
LogFile="[TI]/webapps/awstats/WEB-INF/tools/logresolvemerge.pl [TI]/logs/www_mydomain_com*.log |"
Important! Don't omit the asterisk in pointing the log files. Take in mind that Tomcat will create an access log file for each day, and that final file's name will include the date.