设为首页 收藏本站
查看: 1328|回复: 0

[经验分享] AWStats 日志分析工具【配置分析其他服务器nginx日志】

[复制链接]

尚未签到

发表于 2019-1-30 08:53:16 | 显示全部楼层 |阅读模式
【千篇一律介绍】
Awstats 是一个免费非常简洁而且强大有个性的统计工具。它可以统计您站点的如下信息:
① 访问量,访问次数,页面浏览量,点击数,数据流量等
② 精确到每月、每日、每小时的数据
③ 访问者国家
④ 访问者 IP
⑤ Robots/Spiders 的统计
⑥ 纺客持续时间
⑦ 对不同 Files type 的统计信息
⑧ Pages-URL 的统计
⑨ 访客操作系统浏览器等信息


从自身使用情况来说,awstats没有统计到每小时的访问人次,觉得不是太好。




【下载】
选择稳定版本,个人喜欢用rpm包,简单方便
http://prdownloads.sourceforge.net/awstats/awstats-7.0-1.noarch.rpm


【安装】
# rpm -Vvh awstats-7.0-1.noarch.rpm
Preparing...                ########################################### [100%]
1:awstats                   ########################################### [100%]


----- AWStats 6.9 - Laurent Destailleur -----
AWStats files have been installed in /usr/local/awstats #awstats安装路径,工具,网页都在这里


If first install, follow instructions in documentation
(/usr/local/awstats/docs/index.html) to setup AWStats in 3 steps:
Step 1 : Install and Setup with awstats_configure.pl (or manually)
Step 2 : Build/Update Statistics with awstats.pl
Step 3 : Read Statistics


【配置】
#cd /usr/local/awstats/tools


# perl awstats_configure_pl  


         ----- AWStats awstats_configure 1.0 (build 1.9) (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):


> /etc/httpd/conf/httpd.conf   # 该处是apache主配置文件的路径,这里配置主要awstats用于web访问的;跟需要监控的web服务器没有关系

-----> Check and complete web server config file '/etc/httpd/conf/httpd.conf'


Add 'Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"'


Add 'Alias /awstatscss "/usr/local/awstats/wwwroot/css/"'


Add 'Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"'


Add 'ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"'


Add '' directive


AWStats directives added to Apache config file.

-----> 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.deamon.com  #该处为统计对像的创建代号,可以起任意名字,如 aa.cn bb.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):


>  #直接Enter 就好,此处是将awstats的配置文件放在/etc/awstats 路径下

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


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



-----> Restart Web server with '/sbin/service httpd restart' #重启apache 服务器,虽然awstats提示apache重启成功,如果你源码安装,需要手动启动下


Stopping httpd: [ OK ]
Starting httpd: [ OK ]

-----> 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.frank.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... #按Enter 键


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


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


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


> perl awstats.pl -update -config=www.frank.com


You can also read your statistics for 'www.frank.com' with URL:


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



Press ENTER to finish...  注: 按Enter 键


【修改】
#cd  /etc/awstats


#vi awstats.www.deamon.com.conf


  LogFile="/var/log/httpd/mylog.log"
  修改为apache 的日志文件
  LogFile="/var/log/nginx/access_log.%YYYY%MM%DD-24"
#access_log.%YYYY%MM%DD-24是指用24小时前的年月日日志文件名,假如今天是20121115,获得的文件就是access_log.20121114
#############################################################################
#+我这里的目录/var/log/nginx/是通过NFS挂载需要监控WEB服务器日志目录
#+NFS设置网上一大堆,我这里就不说了
#+Nginx日志格式
  log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
  access_log  logs/access.log  access;
#############################################################################


LogType来指定日志类型,
   w代表web log file
   F 代表ftp log file
   M 代表mail log file
   S 代表streaming log file
默认的是监控WEB日志类型,不用修改


【生成数据目录】


#mkdir /var/lib/awstats #该目录为awstats的数据库库存放目录,默认是没有创建的




【初始化awstats数据库】


# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www.deamon.com --update
此步骤有可能报权限错误,解决方法是
# chmod u+x /usr/local/awstats/tools/*.pl






最后确保在apche 的主配置文件尾部有如下配置,默认情况下在安装配置awstats后是已经配置好了


... ... ...




Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/local/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"


#
# This is to permit URL access to scripts/files in AWStats directory.
#

    Options None
    AllowOverride None
    Order allow,deny
    Allow from all



【定时执行】
# crontab -e


30 1 * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www.deamon.com --update >/dev/null 2>&1


【访问】
  这是您查看一下awstats 对网站的分析情况
     http://Your-IP/awstats/awstats.pl?config =www.deamon.com








运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-669413-1-1.html 上篇帖子: awstat AS4 下篇帖子: linux下搭建HTTP网站服务器和网站日志分析工具AWStats的使用
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表