The Nginx configuration file needs to be updated constantly in some cases. although AWStats now supports output of analysis results in the form of static web pages, the page layout is not convenient with dynamic web pages generated by Perl, in addition, the conversion tool compiled with Perl is a little slow, and the traffic is low... the Nginx configuration file needs to be updated constantly in some cases. although AWStats now supports output of analysis results in the form of static web pages, the page layout is not convenient with dynamic web pages generated by Perl, in addition, the conversion tool compiled with Perl is a little slow. in the case of low traffic, it is more comfortable to run on Perl + Fast CGI.
First of all, you should refer to the previous article to establish the running environment of PERL + FCGI. this step of preparation is hard enough.
Then start to get started:
1. download the latest version of AWStats, which is basically a Perl package. Therefore, you do not need to use apt-get to decompress it to/usr/local/awstats.
Wget http://prdownloads.sourceforge.net/awstats/awstats-6.95.tar.gz
Tar-xzf awstats-6.95.tar.gz
Music awstats-6.95/usr/local/awstats
2. create a directory for storing awstats analysis data
Mkdir/var/lib/awstats
Chown www-data/var/lib/awstats // This is to allow the awstats page to directly refresh the latest data
Except for the relationship between the Ngin server and the Ngin server, select none.
4. manually edit the Nginx configuration file
1) modify the LogFile path
LogFile = "/var/log/Nginx/access. log"
For logs in compressed format, use LogFile = "zcat/var/log/Nginx/%yyyy-24366mm-24366dd-24.gz | ". Zcat is used here because it uses pipeline output, which consumes less system resources. do not forget the final pipeline operator!
Assume that the log section in/etc/Nginx. conf is defined as follows: (be careful when spaces must be added between variables. otherwise, awstats will not recognize them)
It is easy to know that LogFormat should be set
LogFormat = "% host % logname % time1 % methodurl % code % host_r % bytesd % gzipratio % refererquot % uaquot % otherquot"
The last one selected % otherquot should be $ http_x_forwarded_for not recognized in AWstats 6.95
3) convert AllowToUpdateStatsFromBrowser = 1 to enable the browser to instantly refresh data.
5. update the Awstats analysis record and test the configuration.
If everything is normal, you should see results similar to the following:
Create/Update database for config "/etc/awstats/awstats.yoursite.com. conf" by AWStats version 6.95 (build 1.943)
From data in log file "/var/log/Nginx/access. log "...
Phase 1: First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2: Now process new records (Flush history on disk after 20000 hosts )...
Jumped lines in file: 0
Parsed lines in file: 1234
Found 0 dropped records,
Found 0 successfully upted records,
Found 0 old records,
Found 1234 new qualified records.
6. modify the Nginx configuration file under logrotate. d and update the awstats status before daily log splitting.
Okay, test the http://awstats.yoursite.com, just like the previous article, after entering the password, this time you should see the awstats interface
8. if you need to configure static pages, you can replace awstats. pl
/Usr/local/awstats/tools/awstats_buildstaticpages.pl-update-config = yoursite.com-lang = cn-dir =/usr/local/awstats/wwwroot-awstatsprog =/usr/local/awstats /wwwroot/cgi-bin/awstats. pl.
To update access conditions more frequently, you can add this command to crontab, for example, crontab-e-uwww-data.
Then, adjust the nginx configuration file to display the static webpage.
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