CENTOS6 under the Awstats installation configuration steps detailed

Source: Internet
Author: User
Tags comments geoip iis

Awstats function

One: Traffic, number of visits, page views, clicks, data flow, etc.
Second: Accurate to the monthly, daily, hourly data
Third: Visitor Country
Four: Visitor IP
V: Statistics of the Robots/spiders
VI: Duration of visitors
Seven: Statistics for different files type
Viii. Statistics of Pages-url
Nine: Visitor operating system browser and other information
X.: Other information (search keywords, etc.)


I. Download Source

Download Address: http://www.awstats.org/#DOWNLOAD

Old high recommended download last stable

# Last stable version is 7.3-2014-07-23 07:50
# 2015-01-30 21:50:29
Cd/tmp
wget http://heanet.dl.sourceforge.net/project/awstats/AWStats/7.3/awstats-7.3.tar.gz
TAR-ZXF awstats-7.3.tar.gz

# rename
MV awstats-7.3 Awstats

# move To/usr/share/
# As for why to move to/usr/share/, there is a reason for this
MV Awstats/usr/share/
Cd/usr/share/awstats

# dir Tree
Tree-l 1
.
├──docs
├──readme. Txt
├──tools # Tools is the computing tool we need
└──wwwroot # wwwroot is the Web view we need
II. Configuration Calculation Tools

Next we initialize what we need to compute.

First you need to be clear about the location of several files:

log files (eg./var/log/nginx/xxx.access.log)
configuration file (eg./etc/awstats)
Tool class files (eg./usr/share/awstats/tools)
Below we go into the Tools folder and start the first line.

New configuration file

CD Tools
Perl awstats_configure.pl
Do your want to continue Setup from this NON standard directory [YN]? Y

# Whether to configure the Web server
Config file path (' None ' to skip Web server Setup):
>none

# whether to create a new configuration file
Do and want me to build a new AWStats Config/profile
File (required if install) [y/n]? Y

Your Web site, virtual server or profile name:
>www.111cn.net # you want to analyze the domain name

# This step selects your profile path
In which directory your config file (s)?
Default:/etc/awstats
Directory path to store config file (s) (Enter for default):
>enter

# continue to enter, configuration complete
# Next Customize our configuration file

Vim/etc/awstats/awstats.www.111cn.net.conf
Configure log path

If you want to count, you must specify the path to the statistics log.

AWS provides us with a variety of ways to help us find the right files.

The variables for the configuration path are generally around line 50, where you can find hints for writing paths.

%YYYY # can replace 4-bit years
%YY # can replace 2-bit years
%MM # can replace 2-bit month
%DD # can replace 2-digit days
%HH # can replace 2-hour

%YYYY-%MM-%DD-%HH # is it convenient to automatically replace the current date 2015-01-31-10 (at this time) when the program executes?
There are generally two common forms of specifying log files

# Specify a single file
Logfile= "/var/log/nginx/logs/xxxx.access.log"

# Specify multiple Files
# You need to use the/usr/share/awstats/tools/logresolvemerge.pl script to specify all the log files you need, and then add a character "|" to the final text to indicate merging all the file results.

Logfile= "/usr/share/awstats/tools/logresolvemerge.pl/var/log/nginx/logs/xxx.access.log/var/log/nginx/logs/ Yyy.access.log| "

Configure log format

The general Nginx log format does not require configuration, and if necessary, modify approximately line 122, and the system presets four formats for selection.

# 1-apache or Lotus Notes/domino native combined log format (NCSA combined/xlf/elf log format)
# 2-iis or ISA format (IIS log format). faq-com115 for ISA.
# 3-webstar Native log format.
# 4-apache or Squid native Common log format (NCSA COMMON/CLF log format)
Logformat=1
Specify the calculation results directory

The system calculates the result that needs to be saved on disk, if the path is customized?

Near the configuration file line 203, you can find the default configuration for the system.

Dirdata= "/var/lib/awstats"
# Custom
Dirdata= "Your_path_to/awstats"
# then we need to do some processing on this path's permissions

Chown-r www:www Awstats
# WWW Users we'll create later
Page-Side Refresh Data

If you need to be able to refresh your data proactively in your Web page, find approximately line 239 and modify the content.

Actively refresh Data

# Modify
Allowtoupdatestatsfrombrowser=1
Turn on geographic support

If you want the following results, you need to install and open GEO support.

Geographic support

# Install GEO Support
Yum Install GeoIP geoip-data geoip-devel perl-geo-ip-y

# move to profile around line 1429 after installation
# Uncomment
loadplugin= "GeoIP Geoip_standard/usr/share/geoip/geoip.dat"
Solve Chinese garbled

If the search place is garbled after installing AWS, revise line 1204 and delete the comment.

Loadplugin= "Decodeutfkeys"
Testing and updating configurations

By solving the above problems, we can start testing the configuration correctly.

Perl/usr/share/awstats/wwwroot/cgi-bin/awstats.pl-config=www.111cn.net

------------------------------------------
From the data in log file "/usr/share/awstats/tools/logresolvemerge.pl/var/log/nginx/logs/xxx.access.log/var/log/nginx/ Logs/yyy.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:42302
Found dropped Records,
Found 0 comments,
Found 0 Blank Records,
Found 404 Corrupted Records,
Found 41801 old Records,
Found new qualified records.
------------------------------------------
# If you see this information to show that your profile is not a problem, please check.
At this point, the configuration is complete

Iii. Configuring the server

Configuring Nginx Virtual Hosts

If you carefully browse the/usr/share/awstats/tools directory, you will find a Nginx folder, yes, the source package has provided us with the nginx of the virtual host configuration file, we need to simply modify it!

Old high put the virtual host into the Vhosts folder, and then the main configuration file using include vhost/*.conf reference, is not very convenient!
# Configure the Virtual host
CP awstats-nginx.conf/etc/nginx/vhost/awstats.conf

Vim/etc/nginx/vhosts/awstats.conf
The following is the old high given the configuration sample file, for statistics to view the bound domain name for aws.111cn.net, Port 80.

server {
Listen 80;
server_name aws.111cn.net;
Access_log/var/log/nginx/awstats.access_log main;
Error_log/var/log/nginx/awstats.error_log info;
Root/var/www/localhost/htdocs;
Index index.html;

# Restrict Access
# auth_basic "Restricted";
# auth_basic_user_file/etc/awstats/htpasswd;


# Static awstats files:html files stored in document_root/awstats/
location/awstats/classes/{
alias/usr/share/awstats/wwwroot/classes/;
}

location/awstats/css/{
alias/usr/share/awstats/wwwroot/css/;
}

location/awstats/icon/{
alias/usr/share/awstats/wwwroot/icon/;
}

location/awstats-icon/{
alias/usr/share/awstats/wwwroot/icon/;
}

location/awstats/js/{
alias/usr/share/awstats/wwwroot/js/;
}

location/awstatsicons/{
alias/usr/share/awstats/wwwroot/icon/;
}

# Dynamic Stats.
Location ~ ^/cgi-bin/(awredir|awstats) \.pl {
gzip off;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_param script_filename/usr/share/awstats/wwwroot/cgi-bin/fcgi.php;
Fastcgi_param X_script_filename/usr/share/awstats/wwwroot$fastcgi_script_name;
Fastcgi_param x_script_name $fastcgi _script_name;
Include Fastcgi_params;
}

#Rewrite
Location ~ ^/([a-z0-9-_\.] +)$ {
return $scheme://aws.111cn.net/cgi-bin/awstats.pl?config=$1;
}
}
Default URL: http://aws.111cn.net/cgi-bin/awstats.pl?config=www.111cn.net
Pseudo static post: http://aws.111cn.net/www.111cn.net

Open Certification

Since AWS does not provide a certification module, we use NGINX certification and we need to provide an authentication file for Nginx.

There are two ways to generate this file

1.HTPASSWD command

# paths can be specified by themselves
Htpasswd-c/etc/awstats/htpasswd Username:password
# Delete comments for restrict access in the file
Restrict Access
Auth_basic "Restricted";
AUTH_BASIC_USER_FILE/ETC/AWSTATS/HTPASSWD;


2.PHP generation

$password = ' www.111cn.net ';
Encrypt a password
$password = Crypt ($password, Base64_encode ($password));
Get the encrypted password
Echo $password;
The resulting password is then manually written to the file/etc/awstats/htpasswd, formatted as follows

Username1:xucqmk13tfooe
Username2:yxtfb3xwkombm

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.