Use AWStats to analyze some nginx log records

Source: Internet
Author: User

Introduction: This is a detailed page for [converting] nginx log analysis using AWStats. It introduces PHP, related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 335087 'rolling = 'no'>

Address: http://www.linuxbyte.org/yong-awstats-fen-xi-nginx-ri-zhi-de-yi-xie-ji-lu.html

The system environment is cenots + nginx please read the previous log centos Yum install nginx + PHP-FPM + eaccelerator + MySql
.
AWStats is currently the most popular log analysis tool, which provides more convenient and detailed log analysis than third-party logs.


The default nginx version is 1.0.0. The log format AWStats can be directly identified by logrotate.
Log rollback is performed and logs are truncated every day. In order to get more accurate analysis results and use less system resources as much as possible, I analyze the logs of the previous day every morning and output the results as pure static files. Because
Logrotate compresses old logs. Therefore, you need to modify the logrotate setting so that logs are not compressed.
Modify VI/etc/logrotate. d/nginx

/Var/log/nginx/* log {daily rotate 10 # retain the 10-day log missingok logs empty nocompress # Here the default value is compress compressed log sharedscripts postrotate [! -F/var/run/nginx. pid] | kill-usr1 'cat/var/run/nginx. PID 'endscript}

Download and install AWStats

 
Wget http://prdownloads.sourceforge.net/awstats/awstats-7.0-1.noarch.rpmrpm-IVH awstats-7.0-1.noarch.rpm

Configuration

 
CD/usr/local/AWStats/toolsperl awstats_configure.pl

Because our web server is nginx, check for Web Server install and choose none.

 
-----> Need to create a new config file? Do you want me to build a new AWStats config/profilefile (required if first install) [Y/n]? Y # Here choose y -----> define config file name to createwhat is the name of your web site or profile analysis? Example: www. mysite. comexample: demoyour web site, virtual server or profile name:> www.linuxbyte.org # enter the Domain Name of the website you want to count

Edit/etc/AWStats/awstats.www.linuxbyte.org. conf
Modify the path for adding logfile segments to website logs.

 
Logfile = "/var/log/nginx/www.linuxbyte.org. Access. log.1"

Static file for generating analysis results

 
CD/data/web/linuxbyte.org/awstatscp/usr/local/AWStats/wwwroot/icon /. /-RF/usr/local/AWStats/tools/awstats_buildstaticpages.pl-Config = www.linuxbyte.org-lang = cn-Dir =/web/linuxbyte/AWStats-Update

Since then you can access the http://www.linuxbyte.org/awstats/awstats.www.linuxbyte.org.html to view the analysis results.

Set crontable

 
30 4 ***/usr/local/AWStats/tools/awstats_buildstaticpages.pl-Config = www.linuxbyte.org-lang = cn-Dir =/web/linuxbyte/AWStats-Update

Log analysis is performed at every day, because this is the time when the server is idle.

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/335087.html pageno: 10.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.