Apache configuration and application --AWStats log analysis system (real!)

Apache configuration and application --AWStats log analysis system (real!)

AWStats log analysis system

Perl语言开发的一款开源日志分析系统
可用来分析Apache,Samba,Vsftpd,IIS等服务器的访问日志
信息结合crond等计划任务服务,可对日志内容定期进行分析

surroundings

一台Linux服务主机(192.168.13.132)
一台win7测试pc机

1, yum install bind and http service

[root@localhost ~]# yum install httpd bind -y

2, DNS configuration profiles

[root@localhost ~]# vim /etc/named.conf   ##主配置文件

options {
                listen-on port 53 { any; };      ##将本机监听为所有
                listen-on-v6 port 53 { ::1; };
                directory       "/var/named";
                dump-file       "/var/named/data/cache_dump.db";
                statistics-file "/var/named/data/named_stats.txt";
                memstatistics-file "/var/named/data/named_mem_stats.txt";
                recursing-file  "/var/named/data/named.recursing";
                secroots-file   "/var/named/data/named.secroots";
                allow-query     { any; };      ##允许所有

3, the configuration file arrangement region etc / named.rfc1912.zones)

[root@localhost ~]# vim /etc/named.rfc1912.zones  ##配置区域配置文件
zone "localhost" IN {             ##复制两个模板到下面
                                type master;
                                file "named.localhost";
                                allow-update { none; };
};

zone "kgc.com" IN {              ##修改localhost为kgc.com
                                type master;
                                file "kgc.com.zone";      ##创建区域数据配置文件
                                allow-update { none; };
};

4, the editing area data configuration file (kgc.com.zone)

[root@localhost ~]# cd /var/named/     ##切换到/var/named目录下  
[root@localhost named]# cp -p named.localhost kgc.com.zone   
##复制模板为kgc.com.zone
[root@localhost named]# vim kgc.com.zone  ##编辑区域数据配置文件
[root@localhost named]# systemctl start named   ##开启dns服务
$TTL 1D
@       IN SOA  @ rname.invalid. (
                                                            0       ; serial
                                                            1D      ; refresh
                                                            1H      ; retry
                                                            1W      ; expire
                                                            3H )    ; minimum
                                NS      @
                                A       127.0.0.1
www IN  A       192.168.13.132   ##删除ipv6 添加域名解析地址为本机

5, configure http master configuration file, modify the monitor port, and restart the network services

[root@localhost html]# vim /etc/httpd/conf/httpd.conf     ##修改配置文件
Listen 192.168.13.132:80               ##修改ipv4监听端口
#Listen 80      ##将ipv6端口注释
ServerName www.kgc.com:80       ##修改域名
[root@localhost named]# systemctl stop firewalld.service    ##关闭防火墙
[root@localhost named]# setenforce 0   ##关闭增强功能
[root@localhost html]# systemctl start httpd.service  ##启动网络服务

6, access to testing machine (dns service address 192.168.13.132) test site

Apache configuration and application --AWStats log analysis system (real!)
Apache configuration and application --AWStats log analysis system (real!)

7. Check your log files

[root@localhost html]# cd /var/log/httpd/ ##切换到你的日志文件中
[root@localhost httpd]# cat access_log   ##查看日志文件

Apache configuration and application --AWStats log analysis system (real!)

8, Windows file sharing, remote mount installation using the Linux AWStats

1) In the LAMP package required for Windows will compress to share out the blog related articles before (see here if there are questions)

Apache configuration and application --AWStats log analysis system (real!)

2) use remote file sharing on Linux and mount get to the next / abc directory

[root@localhost httpd]# mkdir /abc   ##创建挂载点/abc
root@lamp ~]# smbclient -L //192.168.10.88/
        Sharename       Type      Comment
        ---------       ----      -------
        LAMP-C7         Disk      

[root@lamp ~]# mount.cifs //192.168.10.88/LAMP-C7 /abc  
##远程挂载软件包到/abc目录

3) to unpack the source opt / directory

[root @ localhost httpd] # cd / abc ## is switched to the mount point
[root @ localhost abc] # tar zxvf awstats-7.6.tar.gz -C / opt ## to extract / opt

4) Configure AWStats

[root@localhost abc]# cd /opt/  ##切换/opt目录下
[root@localhost opt]# ls
awstats-7.6  rh
[root@localhost opt]# mv awstats-7.6/ /usr/local/awstats  
##移动awstats到/usr/local/awstats
[root@localhost opt]# cd /usr/local/  ##切换到此目录
[root@localhost local]# ls
awstats  bin  etc  games  include  lib  lib64  libexec  sbin  share  src
[root@localhost local]# cd awstats/    ##切换到awstats目录下
[root@localhost awstats]# ls
docs  README.md  tools  wwwroot
[root@localhost awstats]# cd tools/    ##切换到tools工具目录下
[root@localhost tools]# ./awstats_configure.pl   ##开始配置 
##以下是配置的内容信息
Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path ('none' to skip web server setup):
> /etc/httpd/conf/httpd.conf     ##填写配置文件路径

Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y  ##确定创建新的配置文件

What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
> www.kgc.com        ##输入你的域名

In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
>     ##回车默认域名对应的配置文件目录

> http://localhost/awstats/awstats.pl?config=www.kgc.com

## This is the URL of the page you want to access our
Press ENTER to finish ...

9, the main configuration file to configure http

[root@localhost tools]# cd /etc/httpd/conf
[root@localhost conf]# vim httpd.conf
<Directory "/usr/local/awstats/wwwroot">      ##大G到末行
        Options None
        AllowOverride None
#    Order allow,deny   ##注释这两个权限设置
#    Allow from all
Require all granted   ##添加允许所有

10, configure the default profile awstats

[root@localhost conf]# cd /etc/awstats/
[root@localhost awstats]# ls
awstats.www.kgc.com.conf
[root@localhost awstats]# vim awstats.www.kgc.com.conf  ##修改配置
LogFile="/var/log/httpd/access_log"   ##修改为access_log日志文件
DirData="/var/lib/awstats"   ##数据保存目录
[root@localhost awstats]# cd /var/lib/
[root@localhost lib]# mkdir awstats   ##创建数据保存目录
[root@localhost lib]# systemctl restart httpd.service  ##重启网站服务

11, enter awstats log analysis system page (the local host amended as www.kgc.com)

Apache configuration and application --AWStats log analysis system (real!)

12, data collection, re-check your page log analysis system

[root@localhost ~]# cd /usr/local/awstats/tools
[root@localhost tools]# ./awstats_updateall.pl now
Apache configuration and application --AWStats log analysis system (real!)

13, to update the data to optimize, optimize the web page address

[root@localhost tools]# crontab -e   ##创建周期性计划任务
*/5 * * * * /usr/local/awstats/tools/awstats_updataall.pl now ##每五分钟刷新一次
[root@localhost tools]# cd /var/www/html  ##切换到站点
[root@localhost html]# vim aws.html  ##优化网页地址

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

Apache configuration and application --AWStats log analysis system (real!)

At this point awstats log analysis system set up complete

thanks for reading! ! !

Guess you like

Origin blog.51cto.com/14080162/2445246