AWStats is a free and powerful log analysis and statistics tool. Therefore, install and record Nginx logs.
The code is as follows: |
Copy code |
# Download awstats and modified configuration files Http://dl.dropboxusercontent.com/u/809946/soft/awstats-7.2.tar.gz wget-c Http://dl.dropboxusercontent.com/u/809946/conf/awstats.imcat.in.conf wget-c Tar-zxvf awstats-7.2.tar.gz Music awstats-7.2/usr/local/awstats Chown-R root: root/usr/local/awstats Chmod-R = rwX/usr/local/awstats Chmod + x/usr/local/awstats/tools/*. pl Chmod + x/usr/local/awstats/wwwroot/cgi-bin/*. pl Mkdir-p/etc/awstats/ # Change imcat. in to your domain name. The Log address is your website log address. Cp awstats. imcat. in. conf/etc/awstats. imcat. in. conf # Create a database Mkdir-p/var/lib/awstats /Usr/local/awstats/wwwroot/cgi-bin/awstats. pl-update-config = imcat. in # Create a directory for generating static files Mkdir-p/www/imcat. in/awstats # Generate static files to the site directory /Usr/local/awstats/tools/awstats_buildstaticpages.pl-update-config = imcat. in-lang = cn-dir =/www/imcat. in/awstats |
Change Nginx configuration
Default
The code is as follows: |
Copy code |
Server { Listen 80; Server_name imcat. in; Root/www/imcat. in; Index index.html; # Add the following Icon directory Location ~ ^/Icon/{# icon Directory Root/usr/local/awstats/wwwroot; Index index.html; Access_log off; } } |
Finally, use the crontab-e command to add a scheduled task to update data every morning.
The code is as follows: |
Copy code |
Shell Crontab-e 00 04 ****/usr/local/awstats/tools/awstats_buildstaticpages.pl-update-config = imcat. in-lang = cn-dir =/www/imcat. in/awstats |