1024programmer Nginx Install and configure awstats statistics in nginx environment

Install and configure awstats statistics in nginx environment

wget http://awstats.sourceforge.net/files/awstats-7.0.tar.gz
tar -zxvf awstats-7.0.tar.gz
mv awstats-7.0 /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
cd /usr/local/awstats/tools
./awstats_configure.pl
# Now enter the configuration file, follow the input below
# none (I am nginx here, not apache, so it is none)
# y (create a new configuration file)
# firefoxbug (based on what domain name)
#
#A SIMPLE config file has been created: /etc/awstats/awstats.firefoxbug.conf
#You should have a look inside to check and change manually main parameters.
#You can then manually update your statistics for ‘firefoxbug’ with command:
#> perl awstats.pl -update -cOnfig=firefoxbug
#You can also build static report pages for ‘firefoxbug’ with command:
#> perl awstats.pl -output=pagetype -cOnfig=firefoxbug
#—–> Create config file ‘/etc/awstats/awstats.firefoxbug.conf’
# Config file /etc/awstats/awstats.firefoxbug.conf create

The above steps will generate a configuration file by default ==>>
/etc/awstats/awstats.firefoxbug.conf

Naming rules for the awstats configuration file: awstats.website.conf

modify configuration file

# vim /etc/awstats/awstats.firefoxbug.conf
# LogFile=”/var/log/httpd/mylog.log” ==>> LogFile=”/path/to/you_website_log_path”

Create a database storage directory for awstats statistical results

mkdir -p /var/lib/awstats
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -cOnfig=firefoxbug
awstats.pl will read the parameters in -config and expand firefoxbug to awstats.firefoxbug.conf
Go to the /etc/awstats directory or the current directory to search, and run the program according to the read configuration file.

Analyzing logs: after running, archive such log statistical results into an AWStats database (plain text);
Then there is the output: in two forms
1.
One is to read the statistical result database output through the cgi program;
2.
One is to run a background script to export the output into a static file;

After the statistical analysis is complete, the results are still in the Awstats database. On Apache, you can directly open the web page of the Perl program to view statistics.
However, Nginx does not support Perl very well, so we need to change the method and use the awstats tool to generate static files from the statistical results. The specific steps are as follows:

Create a directory for storing static files generated by awstats. I use /var/www/HduISA/awstats here

mkdir /var/www/HduISA/awstats
/usr/local/awstats/tools/awstats_buildstaticpages.pl -update -cOnfig=firefoxbug -lang=cn -dir=/var/www/HduISA/awstats/firefoxbug

awstats_buildstaticpages.pl will read the DirData inside according to the parameter of -config
The database configuration file under the path, and then generate a static html file, and the generated file is redirected to /var/www/HduISA/awstats/firefoxbug.

The last is the nginx configuration file, configured according to your own path

server {
listen 80;
server_name localhost;
root /var/www/HduISA;
index index.html;
Location ~ ^/awstats/ { # awstats Static page directory
root /var/www/HduISA/awstats
          autoindex on; #You can catalog browse the directories of your multiple domain names for analysis
Index index.html;
access_log off;
}
theLocation ~ ^/icon/ { # Icon directory
root /usr/local/awstats/wwwroot;
Index index.html;
access_log off;
}
}
View www.yoururl.com/awstats/xxx.html

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/install-and-configure-awstats-statistics-in-nginx-environment/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索