Apache之AWStats分析系统

AWStats 分析系统

AWStats 是使用Perl 语言开发的一款开源日志分析系统,它用来完成自动化的日志统计与分析工作。

1、将安装AWStats 所需软件包传到/opt目录下

awstats-7.6.tar.gz

2、安装 AWStats 软件包

cd /opt
tar zxvf awstats-7.6.tar.gz
mv /opt/awstats-7.6 /usr/local/awstats

在这里插入图片描述

3、为要统计的站点建立配置文件

cd /usr/local/awstats/tools
./awstats_configure.pl
......
Config file path ('none' to skip web server setup):
> /usr/local/httpd/conf/httpd.conf          #输入httpd服务主配置文件的路径
Your web site, virtual server or profile name:
> www.lwh.com                   		   	#输入要统计的站点域名

其它全部是y 或者 回车

在这里插入图片描述

4、修改自动生成的 awstats 访问权限,加载 CGI 模块(Apache 2.4 以上版本需要加载CGI 模块)

vim /usr/local/httpd/conf/httpd.conf
ErrorLog "logs/error_log"
CustomLog "logs/access_log" combined
......
--143行--
<IfModule !mpm_prefork_module>
	LoadModule cgid_module modules/mod_cgid.so		#取消注释
</IfModule>
<IfModule mpm_prefork_module>
	LoadModule cgi_module modules/mod_cgi.so		#取消注释
</IfModule>
......
--跳至末行修改--
<Directory "/usr/local/awstats/wwwroot">
    Options None
    AllowOverride None
    #Order allow,deny			#注释掉					
    #Allow from all				#注释掉
    Require all granted			#添加
</Directory>

在这里插入图片描述
在这里插入图片描述

5、修改站点统计配置文件

vim /etc/awstats/awstats.www.lwh.com.conf
LogFile="/usr/local/httpd/logs/access_log"		#修改访问日志文件位置(由于日志格式问题,不能设置虚拟主机的日志)
DirData="/var/lib/awstats"						#awstats目录默认不存在,需要手动创建


mkdir /var/lib/awstats

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

6、执行日志分析,并设置 cron 计划任务

systemctl restart httpd
cd /usr/local/awstats/tools/
./awstats_updateall.pl now  	#更新数据(根据站点配置文件指定的日志文件路径获取日志数据)
#注意,更新数据前最好先把access.log文件清空后重新访问站点,再获取日志数据。

crontab -e
*/5 * * * * /usr/local/awstats/tools/awstats_updateall.pl now

systemctl start crond

在这里插入图片描述
在这里插入图片描述

7、访问 AWStats 分析系统站点

systemctl stop firewalld
systemctl disable firewalld
setenforce 0

echo "192.168.73.88 www.lwh.com" >> /etc/hosts
浏览器访问
http://www.lwh.com/awstats/awstats.pl?config=www.lwh.com

在这里插入图片描述
在这里插入图片描述

http://www.lwh.com/awstats/awstats.pl?config=www.lwh.com进入浏览器访问
在这里插入图片描述

8、优化网页地址

vim /usr/local/httpd/htdocs/aws.html
<html>
<head>
<meta http-equiv=refresh content="0;url=http://www.lwh.com/awstats/awstats.pl?config=www.lwh.com">
</head>
<body></body>
</html>

HTML 文件结构解释:
<html> </html> :用于HTML文件结构最外层表示的标签	
<head> </head> :用于HTML网页内容描述信息的头标签
<body> </body> :用于显示网页内容的内容标签
<meta> :定义了 HTML 文档中的元数据,比如针对搜索引擎和更新频度的描述和关键词。这里的http-equiv=refresh 用于实现网页自动跳转

浏览器访问
http://www.lwh.com/aws.html

在这里插入图片描述
在这里插入图片描述
这次输入的网址是我们优化过后的
在这里插入图片描述
在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值