Windows Server 2008 R2 installs awstats-7.7 to analyze Tomcat logs

Keywords: Tomcat xml Session Java

Because of the need to record and analyze tomcat's logs, Baidu searched for the software awstats to use, and then made a mistake for two days, recording steps to prevent problems from happening again.

Environment: server 2008 r2, project has been running normally on Tomcat 8, ActivePerl-5.24, awstats-7.7 download address online search bar

       

First, you need to install ActivePerl, a dependency file. This double-click installer can install everything by default. No problem encountered is described in detail.

The next step is to get to the installation topic, decompress the awstats-7.7 download package, create a new folder "awstats" in Tomcat 8\\ directory to store the needed awstats project, copy the docs and tools of the decompressed folder awstats 7.7 folder to the Tomcat 8\ webapps\ awstats directory, and then copy the decompressed folder aws-7.7\ wwroots, css, n, and tools to the decompressed folder aws-7.7\ wwroot js is copied to Tomcat 8 webapps awstats, new folders WEB-INF and META-INF under Tomcat 8\ webapps awstats, cgi-bin under awstats-7.7\ wwroot is copied to WEB-INF, cgi-bin is created under cgi-bin, web.xml is created under WEB-INF, context.xml is created under META-INF, as follows

The code of web.xml under WEB-INF is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
  version="2.4">
  <servlet>
      <servlet-name>cgi</servlet-name>
      <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
      <init-param>
        <param-name>clientInputTimeout</param-name>
        <param-value>100</param-value>
      </init-param>
      <init-param>
        <param-name>debug</param-name>
        <param-value>6</param-value>
      </init-param>
      <init-param>
        <param-name>cgiPathPrefix</param-name>
        <param-value>WEB-INF/cgi-bin</param-value>
      </init-param>
       <load-on-startup>5</load-on-startup>
  </servlet>
  <servlet-mapping>
      <servlet-name>cgi</servlet-name>
      <url-pattern>/cgi-bin/*</url-pattern>
  </servlet-mapping>
  
  <session-config>
    <session-timeout>
      30
    </session-timeout>
  </session-config>
  <welcome-file-list>
    <welcome-file>
      index.jsp
    </welcome-file>
    <welcome-file>
      index.html
    </welcome-file>
    <welcome-file>
      index.htm
    </welcome-file>
  </welcome-file-list>
</web-app>

The context.xml code under META-INF is as follows, meaning you can refer to the tomcat configuration parameters:

            <Context reloadable="true" privileged="true">

            </Context>

Modify the configuration file server.xml under Tomcat 8conf as follows

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"    
               prefix="localhost_access_log." suffix=".log"
	       pattern="combined" fileDateFormat="yyyy-MM-dd" resolveHosts="false"/>

The configuration file tomcat-users.xml under Tomcat 8conf finally adds the following configuration (setting access username and password):

<role rolename="manager-gui"/>
  <user username="aw" password="123456" roles="manager-gui"/>

Replicate servlet-cgi.jar as servlet-api.jar under Tomcat 8 lib (I don't know if this is necessary)

Rename the awstats.model.conf file in WEB-INFcgi-bin directory to common.conf and create a new file awstats.localhost.conf, which reads as follows:

Include "common.conf"
LogFile="D:/Tomcat8/logs/localhost_access_log.%yyyy-%mm-%dd.log"
SiteDomain="localhost"
HostAliases="localhost 127.0.0.1"
DefaultFile="index.jsp"

DirData="data"
DirCgi="/cgi-bin"
DirIcons="/awstats/icon"

AllowToUpdateStatsFromBrowser=1

Finally, restart the tomcat service and use the browser to access it http://localhost:port/awstats/cgi-bin/awstats.pl?config=localhost Enter the set username and password to access

 

Content Segmentation--------------------------------------------------------------------------------------------------------------------------

Conclusion: there are too many holes in the installation. Baidu searched for N methods, and finally spliced it. There was also no TOMCAT8 to start the installation. The restart was always wrong, and the system must be restarted, and the problem of tomcat was turned to solve the problem. It is recommended that you install it step by step, then check the links between files or understand the meaning of parameters after success, and then make custom modifications.

PS: Code content can be used for reference

 

Posted by PascalNouma on Wed, 12 Dec 2018 12:33:07 -0800