AWStats 是一套功能強大的 OpenSource 流量統計工具,它可以分析 Apache, FTP 等伺服器所產生的紀錄檔,再產生清楚詳細的圖表。
AWStats 官方網站:http://www.awstats.org/
參考網頁:
Linux 安裝 AWStats 流量分析 – Linux 技術手札
浮雲雅築: [研究] AWStats 7.2 安裝 (tgz)(CentOS 6.5 x86_64)
1. 進行安裝
# yum install awstats –enablerepo=epel
[@more@]
2. 進行設定
# cd /usr/share/awstats/tools
# ./awstats_configure.pl
—– AWStats awstats_configure 1.0 (build 20140126) (c) Laurent Destailleur —–
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
– You are not an administrator user,
– You want to analyze downloaded log files without web server,
– You want to analyze mail or ftp log files instead of web log files,
– You need to analyze load balanced servers log files,
– You want to ‘understand’ all possible ways to use AWStats…
Read the AWStats documentation (docs/index.html).
—–> Running OS detected: Linux, BSD or Unix
Warning: AWStats standard directory on Linux OS is ‘/usr/local/awstats’.
If you want to use standard directory, you should first move all content
of AWStats distribution from current directory:
/usr/share/awstats
to standard directory:
/usr/local/awstats
And then, run configure.pl from this location.
Do you want to continue setup from this NON standard directory [yN] ?y
—–> Check for web server install
Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:Program filesapache groupapacheconfhttpd.conf
Config file path (‘none’ to skip web server setup):
> /etc/httpd/conf/httpd.conf
—–> Check and complete web server config file ‘/etc/httpd/conf/httpd.conf’
Add ‘Alias /awstatsclasses “/usr/share/awstats/wwwroot/classes/”‘
Add ‘Alias /awstatscss “/usr/share/awstats/wwwroot/css/”‘
Add ‘Alias /awstatsicons “/usr/share/awstats/wwwroot/icon/”‘
Add ‘ScriptAlias /awstats/ “/usr/share/awstats/wwwroot/cgi-bin/”‘
Add ‘<Directory>’ directive
AWStats directives added to Apache config file.
—–> Update model config file ‘/etc/awstats/awstats.model.conf’
File awstats.model.conf updated.
—–> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y
—–> Check for web server install
Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:Program filesapache groupapacheconfhttpd.conf
Config file path (‘none’ to skip web server setup):
> /etc/httpd/conf/httpd.conf
—–> Check and complete web server config file ‘/etc/httpd/conf/httpd.conf’
Add ‘Alias /awstatsclasses “/usr/share/awstats/wwwroot/classes/”‘
Add ‘Alias /awstatscss “/usr/share/awstats/wwwroot/css/”‘
Add ‘Alias /awstatsicons “/usr/share/awstats/wwwroot/icon/”‘
Add ‘ScriptAlias /awstats/ “/usr/share/awstats/wwwroot/cgi-bin/”‘
Add ‘<Directory>’ directive
AWStats directives added to Apache config file.
—–> Update model config file ‘/etc/awstats/awstats.model.conf’
File awstats.model.conf updated.
—–> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y
—–> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
>abc.tces.ilc.edu.tw
—–> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
>
—–> Create config file ‘/etc/awstats/awstats.abc.tces.ilc.edu.tw.conf’
Config file /etc/awstats/awstats.abc.tces.ilc.edu.tw.conf created.
—–> Restart Web server with ‘/sbin/service httpd restart’
Redirecting to /bin/systemctl restart httpd.service
—–> Add update process inside a scheduler
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/usr/share/awstats/wwwroot/cgi-bin/awstats.pl -update -config=abc.tces.ilc.edu.tw
Or if you have several config files and prefer having only one command:
/usr/share/awstats/tools/awstats_updateall.pl now
Press ENTER to continue…
A SIMPLE config file has been created: /etc/awstats/awstats.abc.tces.ilc.edu.tw.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for ‘abc.tces.ilc.edu.tw’ with command:
> perl awstats.pl -update -config=abc.tces.ilc.edu.tw
You can also read your statistics for ‘abc.tces.ilc.edu.tw’ with URL:
> http://localhost/awstats/awstats.pl?config=abc.tces.ilc.edu.tw
Press ENTER to finish…
3. 產生畫面
# /usr/share/awstats/wwwroot/cgi-bin/awstats.pl –update –config=abc.tces.ilc.edu.tw
Create/Update database for config “/etc/awstats/awstats.abc.tces.ilc.edu.tw.conf” by AWStats version 7.4 (build 20150714)
From data in log file “/var/log/httpd/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: 3809
Found 162 dropped records,
Found 0 comments,
Found 0 blank records,
Found 0 corrupted records,
Found 0 old records,
Found 3647 new qualified records.
4. 更新資料,如果出現以下訊息,請執行 第 3 步驟
# /usr/share/awstats/tools/awstats_updateall.pl now
Error: Can’t find AWStats program (‘awstats.pl’).
Use -awstatsprog option to solve this.
如果執行第 3 步驟,還是不行,請執行以下
# cp /usr/share/awstats/tools/awstats_updateall.pl /usr/share/awstats/tools/awstats_updateall.pl.$(date +%F)
# sed -i -e ‘s@awstats.pl@/usr/share/awstats/wwwroot/cgi-bin/awstats.pl@’ /usr/share/awstats/tools/awstats_updateall.pl
# /usr/share/awstats/tools/awstats_updateall.pl now
Running ‘”./awstats.pl” -update -config=abc -configdir=”/etc/awstats”‘ to update config abc
Create/Update database for config “/etc/awstats/awstats.abc.conf” by AWStats version 7.4 (build 20150714)
From data in log file “/var/log/httpd/access_log”…
Phase 1 : First bypass old records, searching new record…
Direct access after last parsed record (after line 3873)
Jumped lines in file: 3873
Found 3873 already parsed records.
Parsed lines in file: 15
Found 1 dropped records,
Found 0 comments,
Found 0 blank records,
Found 0 corrupted records,
Found 0 old records,
Found 14 new qualified records.
Running ‘”./awstats.pl” -update -config=abc.tces.ilc.edu.tw -configdir=”/etc/awstats”‘ to update config abc.tces.ilc.edu.tw
Create/Update database for config “/etc/awstats/awstats.abc.tces.ilc.edu.tw.conf” by AWStats version 7.4 (build 20150714)
From data in log file “/var/log/httpd/access_log”…
Phase 1 : First bypass old records, searching new record…
Direct access after last parsed record (after line 3873)
Jumped lines in file: 3873
Found 3873 already parsed records.
Parsed lines in file: 15
Found 1 dropped records,
Found 0 comments,
Found 0 blank records,
Found 0 corrupted records,
Found 0 old records,
Found 14 new qualified records.
Running ‘”./awstats.pl” -update -config=localhost.localdomain -configdir=”/etc/awstats”‘ to update config localhost.localdomain
Create/Update database for config “/etc/awstats/awstats.localhost.localdomain.conf” by AWStats version 7.4 (build 20150714)
From data in log file “/var/log/httpd/access_log”…
Phase 1 : First bypass old records, searching new record…
Direct access after last parsed record (after line 3873)
Jumped lines in file: 3873
Found 3873 already parsed records.
Parsed lines in file: 15
Found 1 dropped records,
Found 0 comments,
Found 0 blank records,
Found 0 corrupted records,
Found 0 old records,
Found 14 new qualified records.
5. 加入工作排程
# crontab -e
0 1 * * * /usr/share/awstats/tools/awstats_updateall.pl now > /dev/null 2>&1
6. 開啟瀏覽器 http://Server’IP//awstats/awstats.pl