搭建 httpd 日志分析系统

AWStats 是使用 Perl 语言开发的一 款开源日志分析系统,不仅可以 用来分析 Apache 网站日志,  也可以用来分析 Samba、Vsftpd、IIS 等 服务的日志信息。结合 crond 等任务计划服务,可以对不断增长的日 志内容定期进行分析。

工具包连接:
链接: https://pan.baidu.com/s/1FhaE1hOihGFG8TD9GLz3cg
提取码: 0805
链接: https://pan.baidu.com/s/1scFwgA5hc6zB9blkqPwtOg
提取码: 0805
网络配置:主机模式
IP: 172.16.1.1/24
注:缺少环境可自行使用 yum 下载,本次使用的这台 centos7 不需要
安装这次搭建的环境( gcc 环境)
[root@localhost ~ ]# tar zxf awstats - 7.5.tar. gz - C /usr/src/
[root@localhost~ ]# tar zxf httpd - 2.2.17.tar. gz - C /usr/src/
将两个安装包解压到指定目录

安装 httpd

[root@localhost~ ]# cd /usr/src/httpd- 2.2.17/
[root@localhost httpd- 2.2.17]# . /configure -- prefix= /usr/local/httpd -- enable - so -- enable
 -rewrite -- enable - charset - lite -- enable - cgi
[root@localhost httpd - 2.2.17]# make - j8 && make install - j8
[root@localhost httpd- 2.2.17]# ln - s /usr/local/httpd/bin/ * /usr/local/bin/
[root@localhost httpd- 2.2.17]# httpd - v         # 显示版本信息
[root@localhost httpd- 2.2.17]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
[root@localhost httpd- 2.2.17]# vim /etc/init.d/httpd

#chkconfig:35 25 25
#description:haha

在第二和第三行添加上面两句

[root@localhost httpd-2.2.17]# chkconfig --add httpd

[root@localhost httpd-2.2.17]# chkconfig --list httpd

[root@localhost httpd- 2.2.17]# vim /usr/local/httpd/conf/httpd.conf
ServerName www.example.com:80        (98)
Servername www.xxx.com                      (99)

98、99行添加,99的域名随便写

[root@localhost httpd-2.2.17]# httpd -t       #检查配置文件是否有语法错误

Syntax OK

[root@localhost httpd-2.2.17]# cd /usr/local/httpd/htdocs/

[root@localhost htdocs]# mv index.html index.html.bak

[root@localhost htdocs]#输入下面那句
echo "<html><body><h1>My name is nbb</h1><body></html> " >index.html
[root@localhost htdocs]# systemctl stop firewalld

[root@localhost htdocs]# systemctl restart httpd

[root@localhost htdocs]# setenforce 0    # 关闭 selinux
[root@localhost htdocs]# curl 172.16.1.1
<html><body><h1>My name is nbb</h1></body></html>

安装日志分析系统

[root@localhost htdocs]# mv /usr/src/awstats- 7.5/ /usr/local/awstats
[root@localhost htdocs]# cd /usr/local/awstats/tools/
[root@localhost tools]# ./awstats_configure. pl
Config file path (' none ' to skip web server setup):
> /usr/local/httpd/conf/httpd.conf
Do you want me to setup Apache to write' combined '
log files [y/N] ? y
file (required if first install) [y/N] ? y
Your web site, virtual server or profile name:
> www.xxx.com     # 输入前面写的的域名
三次回车
[root@localhost tools]# vim /etc/hosts
172.16.1.1 www.xxx.com
[root@localhost tools]# vim /etc/awstats/awstats.www.wyj.com.conf
LogFile="/usr/local/httpd/logs/access_log"         (50)
DirData="/var/lib/awstats"                                  (220)
50、220行
[root@localhost tools]# mkdir /var/lib/awstats
[root@localhost tools]# crontab- e    # 计划任务
*/5 * * * * /usr/local/awstats/tools/awstats_updateall.pl now &
[root@localhost tools]# systemctl enable crond
[root@localhost tools]# systemctl start crond
[root@localhost tools]# systemctl status crond
[root@localhost tools]# chkconfig-- level 35 crond on
[root@localhost tools]# vim /usr/local/httpd/htdocs/awb.html

<html>
<head>
<meta http-equiv=refresh content="0;
url=http://www.xxx.com/awstats/awstats.pl?config=www.xxx.com">
</head>
<body></body>
</html>

[root@localhost tools]# systemctl restart httpd
[root@localhost tools]# firefox www.xxx.com/awb.html

搭建成功

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值