热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Nginx使用AWStats日志分析的步骤及注意事项

本文介绍了在Centos7操作系统上使用Nginx和AWStats进行日志分析的步骤和注意事项。通过AWStats可以统计网站的访问量、IP地址、操作系统、浏览器等信息,并提供精确到每月、每日、每小时的数据。在部署AWStats之前需要确认服务器上已经安装了Perl环境,并进行DNS解析。

AWstats介绍

Awstats是一个免费非常简洁而且强大有个性的网站日志分析工具。

它可以统计您站点的如下信息:

一:访问量,访问次数,页面浏览量,点击数,数据流量等

二:精确到每月、每日、每小时的数据

三:访问者国家

四:访问者IP

五:Robots/Spiders的统计

六:访客持续时间

七:对不同Files type 的统计信息

八:Pages-URL的统计

九:访客操作系统浏览器等信息

十:其它信息(搜索关键字等等)

环境:

Centos7 操作系统 服务器IP 192.168.30.31。

已经部署好的Nginx服务器我这里使用的是编译安装的。

已经做好的DNS正向解析,通过www.aa.com可以正常访问到该服务器。


部署服务:

安装AWstats之前确认服务器上Perl环境已经安装好。

Nginx使用AWStats日志分析

1、解压并安装AWstats

[root@lin3031 ~]# tar xf awstats-7.6.tar.gz 

[root@lin3031 ~]# mv awstats-7.6 /usr/local/awstats

修改awstats属主属组

[root@lin3031 local]# chown root.root -R /usr/local/awstats/

进入tools目录

[root@lin3031 local]# cd /usr/local/awstats/tools/

2、为www.aa.com站点新建统计配置文件,借助awstats提供的awstats_configure.pl脚本进行创建,

[root@lin3031 tools]# ./awstats_configure.pl


----- AWStats awstats_configure 1.0 (build 20140126) (c) Laurent Destailleur -----

This tool will help you to configure AWStats to analyze statistics for

one web server. You can try to use it to let it do all that is possible

in AWStats setup, however following the step by step manual setup

documentation (docs/index.html) is often a better idea. Above all if:

- You are not an administrator user,

- You want to analyze downloaded log files without web server,

- You want to analyze mail or ftp log files instead of web log files,

- You need to analyze load balanced servers log files,

- You want to 'understand' all possible ways to use AWStats...

Read the AWStats documentation (docs/index.html).


-----> Running OS detected: Linux, BSD or Unix


-----> Check for web server install


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):

> none  #Nginx输入none


Your web server config file(s) could not be found.

You will need to setup your web server manually to declare AWStats

script as a CGI, if you want to build reports dynamically.

See AWStats setup documentation (file docs/index.html)


-----> Update model config file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf'

  File awstats.model.conf updated.


-----> Need to create a new config file ?

Do you want me to build a new AWStats config/profile

file (required if first install) [y/N] ? y  #输入y

-----> Define config file name to create

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.aa.com   #输入需要统计的域名


-----> Define config file path

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):

>       #保持默认并回车


-----> Create config file '/etc/awstats/awstats.www.aa.com.conf'

 Config file /etc/awstats/awstats.www.aa.com.conf created.


-----> Add update process inside a scheduler

Sorry, configure.pl does not support automatic add to cron yet.

You can do it manually by adding the following command to your cron:

/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -cOnfig=www.aa.com

Or if you have several config files and prefer having only one command:

/usr/local/awstats/tools/awstats_updateall.pl now

Press ENTER to continue...  #回车



A SIMPLE config file has been created: /etc/awstats/awstats.www.aa.com.conf

You should have a look inside to check and change manually main parameters.

You can then manually update your statistics for 'www.aa.com' with command:

> perl awstats.pl -update -cOnfig=www.aa.com

You can also build static report pages for 'www.aa.com' with command:

> perl awstats.pl -output=pagetype -cOnfig=www.aa.com


Press ENTER to finish...  #回车

3、修改www.aa.com统计配置文件

[root@lin3031 ~]# vim /etc/awstats/awstats.www.aa.com.conf 

修改nginx日志文件位置

Nginx使用AWStats日志分析

数据目录,awstats目录默认不存在需要创建

Nginx使用AWStats日志分析

创建/var/lib/awstats目录

[root@lin3031 ~]# mkdir -p /var/lib/awstats

4 、更新分析日志文件

[root@lin3031 ~]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -cOnfig=www.aa.com

5、生成静态分析日志网页数据

[root@lin3031 ~]# /usr/local/awstats/tools/awstats_buildstaticpages.pl -update -cOnfig=www.aa.com -lang=cn -dir=/usr/local/awstats/wwwroot -awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl

上述命令解释如下: 

• /usr/local/awstats/tools/awstats_buildstaticpages.pl :awstats静态页面生成工具 

• -update -cOnfig=www.test.com :更新配置域名 

• -lang=cn :语言为中文 

• dir=/usr/local/awstats/wwwroot :统计结果输出的目录 

• awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl :日志更新程序的路径

修改nginx的conf文件使其访问www.aa.com 和www.aa.com/awstats 互不影响

Nginx使用AWStats日志分析o

效果如下

Nginx使用AWStats日志分析


Nginx使用AWStats日志分析


推荐阅读
  • 阿里云系统默认是关闭IPv6模块的,因此使用He.net所提供的TunnelBroker将其接入IPv6网络。下面开始修改系统配置,以便支持v6。操作前 ... [详细]
  • 在安装 Greenplum 的过程中,正确配置 `gpinitsystem_config` 文件是至关重要的一步。本文详细介绍了如何优化该文件,以确保数据库集群的高效初始化和稳定运行。通过调整关键参数,用户可以更好地适应不同的硬件环境和业务需求,从而提升系统的整体性能。 ... [详细]
  • 2017-09-07前端日报精选JavaScriptEventLoop机制详解与Vue.js中实践应用Redux基础与实践如何用js获取虚拟键盘高度?( ... [详细]
  • Envoy 流量分配策略优化
    在本研究中,我们对Envoy的流量分配策略进行了优化,旨在提高系统的稳定性和性能。实验环境包括一个前端代理服务(Envoy,IP地址为172.31.57.10)和五个后端服务。通过调整Envoy的配置,实现了更高效的流量分发和负载均衡,显著提升了整体系统的响应速度和可靠性。 ... [详细]
  • Nginx入门指南:从零开始掌握基础配置与优化技巧
    Nginx入门指南:从零开始掌握基础配置与优化技巧 ... [详细]
  • 前言: 网上搭建k8s的文章很多,但很多都无法按其说明在阿里云ecs服务器成功搭建,所以我就花了些时间基于自己成功搭建k8s的步骤写了个操作手册,希望对想搭建k8s环境的盆友有所帮 ... [详细]
  • 一键将应用部署至远程服务器,体验超乎想象的便捷与高效
    该插件作为IDEA的内置功能,用户可以直接启用,无需额外安装。通过简单的配置,即可实现应用的一键部署至远程服务器,极大地提升了开发效率和便捷性。插件支持镜像管理和容器管理,允许用户与容器进行交互,并且兼容Docker Compose,适用于复杂的多容器应用部署。总结部分详细介绍了插件的使用方法和优势,附带的参考资料和项目源码地址为用户提供更多学习和实践资源。 ... [详细]
  • 在使用 PHP 通过 SSL 安全连接到 MySQLi 数据库服务器时,遇到了一些技术难题。我的环境包括一个 Web 服务器和一个数据库服务器,两者均使用 OpenSSL 生成了证书。尽管证书内容一致,但在尝试从 Web 服务器使用 `mysql` 命令进行连接时,仍然遇到了问题。为了确保连接的安全性和稳定性,需要进一步检查证书配置和 PHP 的 SSL 设置,以排除潜在的配置错误或兼容性问题。 ... [详细]
  • 如何在Linux系统中辨别服务器是否为虚拟机或物理机
    在Linux系统中,可以通过执行特定命令来判断服务器是物理机还是虚拟机。例如,在CentOS系统中,运行 `dmidecode | grep -A16 "System Information"` 命令,查看输出中的“Manufacturer”和“Product Name”字段,这些信息可以帮助用户准确区分服务器的类型。此外,还可以通过检查 `/sys/devices/virtual/dmi/id` 目录下的文件内容,进一步确认服务器的具体型号和制造商信息。 ... [详细]
  • 在 CentOS 7 上部署和配置 RabbitMQ 消息队列系统时,首先需要安装 Erlang,因为 RabbitMQ 是基于 Erlang 语言开发的。具体步骤包括:安装必要的依赖项,下载 Erlang 源码包(可能需要一些时间,请耐心等待),解压源码包,解决可能出现的错误,验证安装是否成功,并将 Erlang 添加到环境变量中。接下来,下载 RabbitMQ 的 tar.xz 压缩包,并进行解压和安装。确保每一步都按顺序执行,以保证系统的稳定性和可靠性。 ... [详细]
  • 在无网络环境下于CentOS 7系统中离线部署Nginx服务器
    nginx背景俄罗斯程序员IgorSysoev创建,于2004年NGINX首次发布,来解决C10K问题(10000并发客户端连接到单个服务器,导致服务器连接数过多崩溃的问题),是一 ... [详细]
  • CentOS 7 网络模式下虚拟机的详细配置指南
     1::虚拟机选择net模式  2:虚拟网络配置 此处的网关和网段与下面的ens-33文件配置要一致由ens-33配置文件向这个配置看齐   3:网卡配置文件vietcsyscon ... [详细]
  • 明特量化1、分析如下代码,编译运行后的结果()publicstaticvoidmain(String[]argsÿ ... [详细]
  • 开发笔记:HyperV虚拟机配置内部网络固定IP 并且连接外网
    2019/10/23Hyper-VCentOS7摘要:Hyper-V中的虚拟机CentOS7能固定I ... [详细]
  • dovecot是一个开源的,为linuxunix-like系统提供imap,pop3服务的软件。dovecot是一个比较新的软件,由timosirainen开发,最初发 ... [详细]
author-avatar
来人把老师拖出I去毙了
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有