环境:
1. tomcat6
2. AWStats7.下载地址:http://awstats.sourceforge.net/
3. Perl.下载地址:http://www.perl.org/
步骤:
一、 安装配置tomcat
1. 安装tomcat
2. 配置tomcat的访问日志:
修改Tomcat的server.xml:
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".log" pattern="combined" fileDateFormat="yyyy-MM-dd" resolveHosts="false"/>
二、下载安装Perl
三、下载AWStats
四、创建awstats app
1. 在Tomcat的webapp目录下建立文件夹awstats
2. 把下载包中的docs目录、tools目录、wwwroot下的classes、js、css、icon等目录(除了cgi-bin目录)复制过来
3. 新建WEB-INF目录,把wwwroot下的cgi-bin目录复制过来。并且在WEB-INF下边新建web.xml,内容如下(其中红色部分为安全配置,学习时可以去掉):
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<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>0</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>
<resource-env-ref>
<description>
Link to the UserDatabase instance from which we request lists of
defined role names. Typically, this will be connected to the global
user database with a ResourceLink element in server.xml or the context
configuration file for the Manager web application.
</description>
<resource-env-ref-name>users</resource-env-ref-name>
<resource-env-ref-type>org.apache.catalina.UserDatabase</resource-env-ref-type>
</resource-env-ref>
<!-- Define a Security Constraint on this Application -->
<security-constraint>
<web-resource-collection>
<web-resource-name>awstats status</web-resource-name>
<url-pattern>/cgi-bin/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>awstats</role-name>
</auth-constraint>
</security-constraint>
<!-- Define the Login Configuration for this Application -->
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Awstats status,username: awstats,password: awstats</realm-name>
</login-config>
<!-- Security roles referenced by this web application -->
<security-role>
<description>
The role that is required to log in to the Manager Application
</description>
<role-name>awstats</role-name>
</security-role>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
4. 新建 META-INF目录,在下面建立文件context.xml,内容如下:
<!-- tomcat 6.0 need privileged is true for CGIServlet --> <Context reloadable="true" privileged="true"> </Context>
5. 最终目录结构如下:
五、 配置 awstats
1. 将 WEB-INF/cgi-bin目录下的awstats.model.conf文件改名为common.conf,新建文件awstats.localhost.conf,内容如下:Include "common.conf"
LogFile="D:/tools/apache-tomcat-6.0.35/logs/localhost_access_log.%yyyy-%mm-%dd.log" SiteDomain="localhost" HostAliases="localhost 127.0.0.1" DefaultFile="index.jsp" #在cgi-bin建立data文件夹 DirData="data" DirCgi="/cgi-bin" DirIcons="/awstats/icon" #允许在web页更新日志,默认为0(命令行更新) AllowToUpdateStatsFromBrowser=1
六、访问地址http://localhost:8080/awstats/cgi-bin/awstats.pl?config=localhost可以看到awstats的统计界面。点击“立即更新”连接,可以更新统计信息
附:附加我自己配置的awstats.rar,供参考