Centos7 下搭建AWStats日志分析服务

it2023-06-04  80

Apache访问控制

1.给http服务添加用户和密码。

[root@jjn2 httpd]# bin/htpasswd -c /usr/local/httpd/conf/.awspwd jjn New password: Re-type new password: Adding password for user jjn

2.编辑http主配置文件设置区域访问权限,并重启服务。

[root@jjn2 httpd]# vim conf/httpd.conf DocumentRoot "/usr/local/httpd/htdocs" <Directory "/usr/local/httpd/htdocs"> AuthName "123123123" #这里可以随便写 AuthType Basic #基础认证 AuthUserFile /usr/local/httpd/conf/.awspwd #密码验证文件 Require valid-user #要求通过认证才能访问 Require all denied #默认全部拒绝 </Directory> [root@jjn2 tools]# systemctl restart httpd

验证效果

AWStats部署与使用

1.上传AWStats.tar包,并解压,转移

[root@jjn2 ~]# tar zxf awstats-7.7.tar.gz [root@jjn2 ~]# mv awstats-7.7 /usr/local/awstats

2.为要统计的站点建立配置文件

[root@jjn2 ~]# cd /usr/local/awstats/tools/ [root@jjn2 tools]# chmod +x awstats_configure.pl #给awstats_configure.pl 添加执行权限 [root@jjn2 tools]./awstats_configure.pl Config file path ('none' to skip web server setup): > /usr/local/httpd/conf/httpd.conf #指定httpd主配置文件的路径 you want me to build a new AWStats config/profile file (required if first install) [y/N] ? y #确认创建新的站点配置文件 Your web site, virtual server or profile name: > www.baidu.com #指定要统计的目标网站名称 回车 #接受默认设置 回车

3.修改awstats的访问权限

[root@jjn2 htdocs]# vim /usr/local/httpd/conf/httpd.conf <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>

4.修改站点的统计配置文件

[root@jjn2 htdocs]# vim /etc/awstats/awstats.www.baidu.com.conf LogFile="/usr/local/httpd/logs/access_log" #指定需要分析的Web日志文件 DirData="/var/lib/awstats" #用来存放统计数据的目录 [root@jjn2 htdocs]# mkdir /var/lib/awstats #创建用来存放统计数据的目录

5.,修改文件权限,执行日志分析

[root@jjn2 htdocs]# cd /usr/local/awstats/tools/ [root@jjn2 tools]# chmod +x awstats_updateall.pl [root@jjn2 tools]# ./awstats_updateall.pl now

6.为方便访问,建立跳转网页用来访问AWStats

[root@jjn2 tools]# vim /usr/local/httpd/htdocs/info.html <html> <head> <meta http-equiv=refresh content="0; url=http://www.baidu.com/awstats/awstats.pl?config=www.baidu.com"> </head> <boby></boby> </html>

7.实际访问效果

最新回复(0)