linux Apache 环境下安装AWStatsWEB日志分析工具
程序员文章站
2022-06-04 14:01:12
今天安装了awstats(AWStats是在Sourceforge上发展很快的一个基于Perl的WEB日志分析工具。),好好折腾了一把,终于搞完了... 12-11-27...
今天安装了awstats(awstats是在sourceforge上发展很快的一个基于perl的web日志分析工具。),好好折腾了一把,终于搞完了,参考了不少资料,将主要步骤和遇到的问题分享一下。
1.在home下建一个目录awstats,cd /home/awstats
2.wget http://awstats.sourceforge.net/files/awstats-7.0.tar.gz,下载awstats最新版本7.0
3.安装
[root@jmappser tools]# perl awstats_configure.pl
----- awstats awstats_configure 1.0 (build 1.9) (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
-----> check for web server install
found web server apache config file '/usr/local/apache/conf/httpd.conf'
-----> check and complete web server config file '/usr/local/apache/conf/httpd.conf'
add 'alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"'
add 'alias /awstatscss "/usr/local/awstats/wwwroot/css/"'
add 'alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"'
add 'scriptalias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"'
add '<directory>' directive
awstats directives added to apache config file.
-----> update model config file '/usr/local/awstats/wwwroot/cgi-bin/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:
> www.b2bweb.co
-----> 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):
> /usr/local/awstats/config
-----> create config file '/usr/local/awstats/config/awstats.www.b2bweb.co.conf'
config file /usr/local/awstats/config/awstats.www.b2bweb.co.conf created.
-----> restart web server with '/sbin/service httpd restart'
usage: /etc/init.d/httpd [-d name] [-d directory] [-f file]
[-c "directive"] [-c "directive"]
[-k start|restart|graceful|graceful-stop|stop]
[-v] [-v] [-h] [-l] [-l] [-t] [-s]
options:
-d name : define a name for use in <ifdefine name> directives
-d directory : specify an alternate initial serverroot
-f file : specify an alternate serverconfigfile
-c "directive" : process directive before reading config files
-c "directive" : process directive after reading config files
-e level : show startup errors of level (see loglevel)
-e file : log startup errors to file
-v : show version number
-v : show compile settings
-h : list available command line options (this page)
-l : list compiled in modules
-l : list available configuration directives
-t -d dump_vhosts : show parsed settings (currently only vhost settings)
-s : a synonym for -t -d dump_vhosts
-t -d dump_modules : show all loaded modules
-m : a synonym for -t -d dump_modules
-t : run syntax check for config files
-----> 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/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.b2bweb.co
or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
press enter to continue...
a simple config file has been created: /usr/local/awstats/config/awstats.www.b2bweb.co.conf
you should have a look inside to check and change manually main parameters.
you can then manually update your statistics for 'www.b2bweb.co' with command:
> perl awstats.pl -update -config=www.b2bweb.co
you can also read your statistics for 'www.b2bweb.co' with url:
> http://localhost/awstats/awstats.pl?config=www.b2bweb.co
press enter to finish...
[root@jmappser tools]# cp /usr/loca/awstats/wwwroot/icon /usr/local/apache/htdocs/awstatsicons -rf
cp: 无法 stat “/usr/loca/awstats/wwwroot/icon”: 没有那个文件或目录
[root@jmappser tools]#
[root@jmappser tools]#
[root@jmappser tools]# ls
awstats_buildstaticpages.pl awstats_exportlib.pl geoip_generator.pl logresolvemerge.pl nginx webmin
awstats_configure.pl awstats_updateall.pl httpd_conf maillogconvert.pl urlaliasbuilder.pl xslt
[root@jmappser tools]# cd ..
[root@jmappser awstats]# ls
awstats-7.0 awstats-7.1 awstats-7.1.zip config docs readme.txt tools wwwroot
[root@jmappser awstats]# ll
总计 1508
drwxr-xr-x 5 1000 1000 4096 2010-12-06 awstats-7.0
drwxr-xr-x 5 root root 4096 11-22 17:52 awstats-7.1
-rw-r--r-- 1 root root 1505352 11-22 18:02 awstats-7.1.zip
drwxr-xr-x 2 root root 4096 11-25 10:21 config
drwxr-xr-x 4 root root 4096 11-22 18:04 docs
-rw-r--r-- 1 root root 6787 11-22 18:04 readme.txt
drwxr-xr-x 5 root root 4096 11-22 18:04 tools
drwxr-xr-x 7 root root 4096 11-22 18:04 wwwroot
[root@jmappser awstats]# cd wwwroot/
[root@jmappser wwwroot]# ls
cgi-bin classes css icon js
[root@jmappser wwwroot]# cp icon/ /usr/local/jiemai/apache-blogs/htdocs/awstatsicons -rf
[root@jmappser wwwroot]#
[root@jmappser wwwroot]#
[root@jmappser wwwroot]# pwd
/usr/local/awstats/wwwroot
[root@jmappser wwwroot]# cd ..
[root@jmappser awstats]# ls
awstats-7.0 awstats-7.1 awstats-7.1.zip config docs readme.txt tools wwwroot
[root@jmappser awstats]# ls
awstats-7.0 awstats-7.1 awstats-7.1.zip config docs readme.txt tools wwwroot
[root@jmappser awstats]# ll
总计 1508
drwxr-xr-x 5 1000 1000 4096 2010-12-06 awstats-7.0
drwxr-xr-x 5 root root 4096 11-22 17:52 awstats-7.1
-rw-r--r-- 1 root root 1505352 11-22 18:02 awstats-7.1.zip
drwxr-xr-x 2 root root 4096 11-25 10:21 config
drwxr-xr-x 4 root root 4096 11-22 18:04 docs
-rw-r--r-- 1 root root 6787 11-22 18:04 readme.txt
drwxr-xr-x 5 root root 4096 11-22 18:04 tools
drwxr-xr-x 7 root root 4096 11-22 18:04 wwwroot
[root@jmappser awstats]# cd config/
[root@jmappser config]# ls
awstats.www.b2bweb.co.conf
[root@jmappser config]# vi awstats.www.b2bweb.co.conf
# awstats configure file 7.0
#-----------------------------------------------------------------------------
# copy this file into awstats.www.mydomain.conf and edit this new config file
# to setup awstats (see documentation in docs/ directory).
# the config file must be in /etc/awstats, /usr/local/etc/awstats or /etc (for
# unix/linux) or same directory than awstats.pl (windows, mac, unix/linux...)
# to include an environment variable in any parameter (awstats will replace
# it with its value when reading it), follow the example:
# parameter="__envname__"
# note that environment variable awstats_current_config is always defined with
# the config value in an awstats running session and can be used like others.
#-----------------------------------------------------------------------------
# $revision: 1.353 $ - $author: eldy $ - $date: 2012/02/15 14:19:22 $
#-----------------------------------------------------------------------------
# main setup section (required to make awstats work)
#-----------------------------------------------------------------------------
# "logfile" contains the web, ftp or mail server log file to analyze.
# possible values: a full path, or a relative path from awstats.pl directory.
# example: "/var/log/apache/access.log"
# example: "../logs/mycombinedlog.log"
# you can also use tags in this filename if you need a dynamic file name
# depending on date or time (replacement is made by awstats at the beginning
# of its execution). this is available tags :
# %yyyy-n is replaced with 4 digits year we were n hours ago
# %yy-n is replaced with 2 digits year we were n hours ago
# %mm-n is replaced with 2 digits month we were n hours ago
# %mo-n is replaced with 3 letters month we were n hours ago
# %dd-n is replaced with day we were n hours ago
# %hh-n is replaced with hour we were n hours ago
# %ns-n is replaced with number of seconds at 00:00 since 1970
# %wm-n is replaced with the week number in month (1-5)
# %wm-n is replaced with the week number in month (0-4)
# %wy-n is replaced with the week number in year (01-52)
# %wy-n is replaced with the week number in year (00-51)
# %dw-n is replaced with the day number in week (1-7, 1=sunday)
# use n=24 if you need (1-7, 1=monday)
# %dw-n is replaced with the day number in week (0-6, 0=sunday)
# use n=24 if you need (0-6, 0=monday)
# use 0 for n if you need current year, month, day, hour...
# example: "/var/log/access_log.%yyyy-0%mm-0%dd-0.log"
# example: "c:/winnt/system32/logfiles/w3svc1/ex%yy-24%mm-24%dd-24.log"
# you can also use a pipe if log file come from a pipe :
# example: "gzip -d </var/log/apache/access.log.gz |"
# if there are several log files from load balancing servers :
# example: "/pathtotools/logresolvemerge.pl *.log |"
#
#logfile="/var/log/httpd/mylog.log"
logfile="/usr/local/jiemai/apache-blogs/logs/access_logs"
/dirdata
# note: result of dns lookup can be used to build the country report. however
# it is highly recommanded to enable the plugin 'geoip' or 'geoipfree' to
# have an accurate country report with no need of dns lookup.
# possible values:
# 0 - no dns lookup
# 1 - dns lookup is fully enabled
# 2 - dns lookup is made only from static dns cache file (if it exists)
# default: 2
dnslookup=2
# when awstats updates its statistics, it stores results of its analysis in
# files (awstats database). all those files are written in the directory
# defined by the "dirdata" parameter. set this value to the directory where
# you want awstats to save its database and working files into.
# warning: if you want to be able to use the "allowtoupdatestatsfrombrowser"
# feature (see later), you need "write" permissions by web server user on this
# directory (and "modify" for windows ntfs file systems).
# example: "/var/lib/awstats"
# example: "../data"
# example: "c:/awstats_data_dir"
# default: "." (means same directory as awstats.pl)
dirdata="/usr/local/awstats/data"
# relative or absolute web url of your awstats cgi-bin directory.
# this parameter is used only when awstats is run from command line
# with -output option (to generate links in html reported page).
# example: "/awstats"
# default: "/cgi-bin" (means awstats.pl is in "/yourwwwroot/cgi-bin")
#
dircgi="/usr/local/awstats/wwwroot/cgi-bin"
/allowtoupdatestatsfrombrowser
# when this parameter is set to 1, awstats adds a button on report page to
# allow to "update" statistics from a web browser. warning, when "update" is
# made from a browser, awstats is run as a cgi by the web server user defined
# in your web server (user "nobody" by default with apache, "iusr_xxx" with
# iis), so the "dirdata" directory and all already existing history files
# awstatsmmyyyy[.xxx].txt must be writable by this user. change permissions if
# necessary to "read/write" (and "modify" for windows ntfs file systems).
# warning: update process can be long so you might experience "time out"
# browser errors if you don't launch awstats frequently enough.
# when set to 0, update is only made when awstats is run from the command
# line interface (or a task scheduler).
# possible values: 0 or 1
# default: 0
#
allowtoupdatestatsfrombrowser=1
# awstats saves and sorts its database on a month basis (except if using
# databasebreak option from command line).
# however, if you choose the -month=all from command line or
# value '-year-' from cgi combo form to have a report for all year, awstats
# needs to reload all data for full year (each month), and sort them,
# requiring a large amount of time, memory and cpu. this might be a problem
# for web hosting providers that offer awstats for large sites, on shared
# servers, to non cpu cautious customers.
# for this reason, the 'full year' is only enabled on command line by default.
# you can change this by setting this parameter to 0, 1, 2 or 3.
# possible values:
# 0 - never allowed
# 1 - allowed on cli only, -year- value in combo is not visible
"awstats.www.b2bweb.co.conf" 1557l, 62015c written
[root@jmappser config]# chown -r root:root /usr/local/awstats
[root@jmappser config]# chmod -r 755 /usr/local/awstats
[root@jmappser config]# mkdir /usr/local/awstats/data
[root@jmappser config]# chown nobody.nobody /usr/local/awstats/data
[root@jmappser config]# chmod 777 data
chmod: 无法访问 “data”: 没有那个文件或目录
[root@jmappser config]# cd ..
[root@jmappser awstats]# ls
awstats-7.0 awstats-7.1 awstats-7.1.zip config data docs readme.txt tools wwwroot
[root@jmappser awstats]# chmod 777 data
[root@jmappser awstats]# chmod 755 /usr/local/awstats/wwwroot/cgi-bin/*.pl
tar zxf awstats-7.0.tar.gz
mv awstats-7.0 /usr/local/awstats
cd /usr/local/awstats/tools
perl awstats_configure.pl
在[y/n]提示时,输入y
your web site, virtual server or profile name: 这时输入要被分析的域名
其他按<enter>
press enter to finish。。。完成安装
4.修改文件目录
cp /usr/loca/awstats/wwwroot/icon /usr/local/apache/htdocs/awstatsicons -rf
5.配置
vi /etc/awstats/awstats.上面输入的域名.conf
logfile="/usr/local/apache/logs/access_logs"
dirdata="/usr/local/awstats/data"
dircgi="/usr/local/awstats/wwwroot/cgi-bin"
allowtoupdatestatsfrombrowser=1
6.设置权限
chown -r root:root /usr/local/awstats
chmod -r 755 /usr/local/awstats
mkdir /usr/local/awstats/data
chown nobody.nobody /usr/local/awstats/data
chmod 777 data
chmod 755 /usr/local/awstats/wwwroot/cgi-bin/*.pl
7.生成分析日志与静态查看界面
cd /usr/local/awstats/wwwroot/cgi-bin
perl awstats.pl -config=上面域名 -update -lang=cn
perl awstats.pl -config=上面域名 -output -staticlinks -lang=cn>awstats.上面域名.html
8.测试 http://上面的域名/awstats/awstats.pl?config=上面的域名
遇到的问题:
1.perl awstats.pl -config=上面域名 -update -lang=cn提示出错,或在测试时提示出错。logformat不正确:
原因:access_logs格式不正确,删除access_logs,重启apache。搞定
2.测试时看图片显示不了。
原因:/etc/awstats/awstats.上面输入的域名.conf中的diricons配置不正确,这个目录一定要从/usr/local/apache/htdocs目录开始算,相对目录,要确保配置的目录可能过http访问到
3.点击测试页面的“立即更新”时,提示"xxxx.tmp"无法存储
原因:/usr/local/awstats/data的权限不正确,需要使用nobody权限,赋777.
1.在home下建一个目录awstats,cd /home/awstats
2.wget http://awstats.sourceforge.net/files/awstats-7.0.tar.gz,下载awstats最新版本7.0
3.安装
复制代码
代码如下:[root@jmappser tools]# perl awstats_configure.pl
----- awstats awstats_configure 1.0 (build 1.9) (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
-----> check for web server install
found web server apache config file '/usr/local/apache/conf/httpd.conf'
-----> check and complete web server config file '/usr/local/apache/conf/httpd.conf'
add 'alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"'
add 'alias /awstatscss "/usr/local/awstats/wwwroot/css/"'
add 'alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"'
add 'scriptalias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"'
add '<directory>' directive
awstats directives added to apache config file.
-----> update model config file '/usr/local/awstats/wwwroot/cgi-bin/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:
> www.b2bweb.co
-----> 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):
> /usr/local/awstats/config
-----> create config file '/usr/local/awstats/config/awstats.www.b2bweb.co.conf'
config file /usr/local/awstats/config/awstats.www.b2bweb.co.conf created.
-----> restart web server with '/sbin/service httpd restart'
usage: /etc/init.d/httpd [-d name] [-d directory] [-f file]
[-c "directive"] [-c "directive"]
[-k start|restart|graceful|graceful-stop|stop]
[-v] [-v] [-h] [-l] [-l] [-t] [-s]
options:
-d name : define a name for use in <ifdefine name> directives
-d directory : specify an alternate initial serverroot
-f file : specify an alternate serverconfigfile
-c "directive" : process directive before reading config files
-c "directive" : process directive after reading config files
-e level : show startup errors of level (see loglevel)
-e file : log startup errors to file
-v : show version number
-v : show compile settings
-h : list available command line options (this page)
-l : list compiled in modules
-l : list available configuration directives
-t -d dump_vhosts : show parsed settings (currently only vhost settings)
-s : a synonym for -t -d dump_vhosts
-t -d dump_modules : show all loaded modules
-m : a synonym for -t -d dump_modules
-t : run syntax check for config files
-----> 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/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.b2bweb.co
or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
press enter to continue...
a simple config file has been created: /usr/local/awstats/config/awstats.www.b2bweb.co.conf
you should have a look inside to check and change manually main parameters.
you can then manually update your statistics for 'www.b2bweb.co' with command:
> perl awstats.pl -update -config=www.b2bweb.co
you can also read your statistics for 'www.b2bweb.co' with url:
> http://localhost/awstats/awstats.pl?config=www.b2bweb.co
press enter to finish...
[root@jmappser tools]# cp /usr/loca/awstats/wwwroot/icon /usr/local/apache/htdocs/awstatsicons -rf
cp: 无法 stat “/usr/loca/awstats/wwwroot/icon”: 没有那个文件或目录
[root@jmappser tools]#
[root@jmappser tools]#
[root@jmappser tools]# ls
awstats_buildstaticpages.pl awstats_exportlib.pl geoip_generator.pl logresolvemerge.pl nginx webmin
awstats_configure.pl awstats_updateall.pl httpd_conf maillogconvert.pl urlaliasbuilder.pl xslt
[root@jmappser tools]# cd ..
[root@jmappser awstats]# ls
awstats-7.0 awstats-7.1 awstats-7.1.zip config docs readme.txt tools wwwroot
[root@jmappser awstats]# ll
总计 1508
drwxr-xr-x 5 1000 1000 4096 2010-12-06 awstats-7.0
drwxr-xr-x 5 root root 4096 11-22 17:52 awstats-7.1
-rw-r--r-- 1 root root 1505352 11-22 18:02 awstats-7.1.zip
drwxr-xr-x 2 root root 4096 11-25 10:21 config
drwxr-xr-x 4 root root 4096 11-22 18:04 docs
-rw-r--r-- 1 root root 6787 11-22 18:04 readme.txt
drwxr-xr-x 5 root root 4096 11-22 18:04 tools
drwxr-xr-x 7 root root 4096 11-22 18:04 wwwroot
[root@jmappser awstats]# cd wwwroot/
[root@jmappser wwwroot]# ls
cgi-bin classes css icon js
[root@jmappser wwwroot]# cp icon/ /usr/local/jiemai/apache-blogs/htdocs/awstatsicons -rf
[root@jmappser wwwroot]#
[root@jmappser wwwroot]#
[root@jmappser wwwroot]# pwd
/usr/local/awstats/wwwroot
[root@jmappser wwwroot]# cd ..
[root@jmappser awstats]# ls
awstats-7.0 awstats-7.1 awstats-7.1.zip config docs readme.txt tools wwwroot
[root@jmappser awstats]# ls
awstats-7.0 awstats-7.1 awstats-7.1.zip config docs readme.txt tools wwwroot
[root@jmappser awstats]# ll
总计 1508
drwxr-xr-x 5 1000 1000 4096 2010-12-06 awstats-7.0
drwxr-xr-x 5 root root 4096 11-22 17:52 awstats-7.1
-rw-r--r-- 1 root root 1505352 11-22 18:02 awstats-7.1.zip
drwxr-xr-x 2 root root 4096 11-25 10:21 config
drwxr-xr-x 4 root root 4096 11-22 18:04 docs
-rw-r--r-- 1 root root 6787 11-22 18:04 readme.txt
drwxr-xr-x 5 root root 4096 11-22 18:04 tools
drwxr-xr-x 7 root root 4096 11-22 18:04 wwwroot
[root@jmappser awstats]# cd config/
[root@jmappser config]# ls
awstats.www.b2bweb.co.conf
[root@jmappser config]# vi awstats.www.b2bweb.co.conf
# awstats configure file 7.0
#-----------------------------------------------------------------------------
# copy this file into awstats.www.mydomain.conf and edit this new config file
# to setup awstats (see documentation in docs/ directory).
# the config file must be in /etc/awstats, /usr/local/etc/awstats or /etc (for
# unix/linux) or same directory than awstats.pl (windows, mac, unix/linux...)
# to include an environment variable in any parameter (awstats will replace
# it with its value when reading it), follow the example:
# parameter="__envname__"
# note that environment variable awstats_current_config is always defined with
# the config value in an awstats running session and can be used like others.
#-----------------------------------------------------------------------------
# $revision: 1.353 $ - $author: eldy $ - $date: 2012/02/15 14:19:22 $
#-----------------------------------------------------------------------------
# main setup section (required to make awstats work)
#-----------------------------------------------------------------------------
# "logfile" contains the web, ftp or mail server log file to analyze.
# possible values: a full path, or a relative path from awstats.pl directory.
# example: "/var/log/apache/access.log"
# example: "../logs/mycombinedlog.log"
# you can also use tags in this filename if you need a dynamic file name
# depending on date or time (replacement is made by awstats at the beginning
# of its execution). this is available tags :
# %yyyy-n is replaced with 4 digits year we were n hours ago
# %yy-n is replaced with 2 digits year we were n hours ago
# %mm-n is replaced with 2 digits month we were n hours ago
# %mo-n is replaced with 3 letters month we were n hours ago
# %dd-n is replaced with day we were n hours ago
# %hh-n is replaced with hour we were n hours ago
# %ns-n is replaced with number of seconds at 00:00 since 1970
# %wm-n is replaced with the week number in month (1-5)
# %wm-n is replaced with the week number in month (0-4)
# %wy-n is replaced with the week number in year (01-52)
# %wy-n is replaced with the week number in year (00-51)
# %dw-n is replaced with the day number in week (1-7, 1=sunday)
# use n=24 if you need (1-7, 1=monday)
# %dw-n is replaced with the day number in week (0-6, 0=sunday)
# use n=24 if you need (0-6, 0=monday)
# use 0 for n if you need current year, month, day, hour...
# example: "/var/log/access_log.%yyyy-0%mm-0%dd-0.log"
# example: "c:/winnt/system32/logfiles/w3svc1/ex%yy-24%mm-24%dd-24.log"
# you can also use a pipe if log file come from a pipe :
# example: "gzip -d </var/log/apache/access.log.gz |"
# if there are several log files from load balancing servers :
# example: "/pathtotools/logresolvemerge.pl *.log |"
#
#logfile="/var/log/httpd/mylog.log"
logfile="/usr/local/jiemai/apache-blogs/logs/access_logs"
/dirdata
# note: result of dns lookup can be used to build the country report. however
# it is highly recommanded to enable the plugin 'geoip' or 'geoipfree' to
# have an accurate country report with no need of dns lookup.
# possible values:
# 0 - no dns lookup
# 1 - dns lookup is fully enabled
# 2 - dns lookup is made only from static dns cache file (if it exists)
# default: 2
dnslookup=2
# when awstats updates its statistics, it stores results of its analysis in
# files (awstats database). all those files are written in the directory
# defined by the "dirdata" parameter. set this value to the directory where
# you want awstats to save its database and working files into.
# warning: if you want to be able to use the "allowtoupdatestatsfrombrowser"
# feature (see later), you need "write" permissions by web server user on this
# directory (and "modify" for windows ntfs file systems).
# example: "/var/lib/awstats"
# example: "../data"
# example: "c:/awstats_data_dir"
# default: "." (means same directory as awstats.pl)
dirdata="/usr/local/awstats/data"
# relative or absolute web url of your awstats cgi-bin directory.
# this parameter is used only when awstats is run from command line
# with -output option (to generate links in html reported page).
# example: "/awstats"
# default: "/cgi-bin" (means awstats.pl is in "/yourwwwroot/cgi-bin")
#
dircgi="/usr/local/awstats/wwwroot/cgi-bin"
/allowtoupdatestatsfrombrowser
# when this parameter is set to 1, awstats adds a button on report page to
# allow to "update" statistics from a web browser. warning, when "update" is
# made from a browser, awstats is run as a cgi by the web server user defined
# in your web server (user "nobody" by default with apache, "iusr_xxx" with
# iis), so the "dirdata" directory and all already existing history files
# awstatsmmyyyy[.xxx].txt must be writable by this user. change permissions if
# necessary to "read/write" (and "modify" for windows ntfs file systems).
# warning: update process can be long so you might experience "time out"
# browser errors if you don't launch awstats frequently enough.
# when set to 0, update is only made when awstats is run from the command
# line interface (or a task scheduler).
# possible values: 0 or 1
# default: 0
#
allowtoupdatestatsfrombrowser=1
# awstats saves and sorts its database on a month basis (except if using
# databasebreak option from command line).
# however, if you choose the -month=all from command line or
# value '-year-' from cgi combo form to have a report for all year, awstats
# needs to reload all data for full year (each month), and sort them,
# requiring a large amount of time, memory and cpu. this might be a problem
# for web hosting providers that offer awstats for large sites, on shared
# servers, to non cpu cautious customers.
# for this reason, the 'full year' is only enabled on command line by default.
# you can change this by setting this parameter to 0, 1, 2 or 3.
# possible values:
# 0 - never allowed
# 1 - allowed on cli only, -year- value in combo is not visible
"awstats.www.b2bweb.co.conf" 1557l, 62015c written
[root@jmappser config]# chown -r root:root /usr/local/awstats
[root@jmappser config]# chmod -r 755 /usr/local/awstats
[root@jmappser config]# mkdir /usr/local/awstats/data
[root@jmappser config]# chown nobody.nobody /usr/local/awstats/data
[root@jmappser config]# chmod 777 data
chmod: 无法访问 “data”: 没有那个文件或目录
[root@jmappser config]# cd ..
[root@jmappser awstats]# ls
awstats-7.0 awstats-7.1 awstats-7.1.zip config data docs readme.txt tools wwwroot
[root@jmappser awstats]# chmod 777 data
[root@jmappser awstats]# chmod 755 /usr/local/awstats/wwwroot/cgi-bin/*.pl
tar zxf awstats-7.0.tar.gz
mv awstats-7.0 /usr/local/awstats
cd /usr/local/awstats/tools
perl awstats_configure.pl
在[y/n]提示时,输入y
your web site, virtual server or profile name: 这时输入要被分析的域名
其他按<enter>
press enter to finish。。。完成安装
4.修改文件目录
cp /usr/loca/awstats/wwwroot/icon /usr/local/apache/htdocs/awstatsicons -rf
5.配置
vi /etc/awstats/awstats.上面输入的域名.conf
logfile="/usr/local/apache/logs/access_logs"
dirdata="/usr/local/awstats/data"
dircgi="/usr/local/awstats/wwwroot/cgi-bin"
allowtoupdatestatsfrombrowser=1
6.设置权限
chown -r root:root /usr/local/awstats
chmod -r 755 /usr/local/awstats
mkdir /usr/local/awstats/data
chown nobody.nobody /usr/local/awstats/data
chmod 777 data
chmod 755 /usr/local/awstats/wwwroot/cgi-bin/*.pl
7.生成分析日志与静态查看界面
cd /usr/local/awstats/wwwroot/cgi-bin
perl awstats.pl -config=上面域名 -update -lang=cn
perl awstats.pl -config=上面域名 -output -staticlinks -lang=cn>awstats.上面域名.html
8.测试 http://上面的域名/awstats/awstats.pl?config=上面的域名
遇到的问题:
1.perl awstats.pl -config=上面域名 -update -lang=cn提示出错,或在测试时提示出错。logformat不正确:
原因:access_logs格式不正确,删除access_logs,重启apache。搞定
2.测试时看图片显示不了。
原因:/etc/awstats/awstats.上面输入的域名.conf中的diricons配置不正确,这个目录一定要从/usr/local/apache/htdocs目录开始算,相对目录,要确保配置的目录可能过http访问到
3.点击测试页面的“立即更新”时,提示"xxxx.tmp"无法存储
原因:/usr/local/awstats/data的权限不正确,需要使用nobody权限,赋777.
推荐阅读
-
Linux+php+apache+oracle环境搭建之CentOS下安装Oracle数据库
-
centos下yum搭建安装linux+apache+mysql+php环境教程
-
linux Apache 环境下安装AWStatsWEB日志分析工具
-
Linux系统下搭建MantisBT环境以及Apache+PHP+MySql的安装
-
Linux+php+apache+oracle环境搭建之CentOS下源码编译安装PHP
-
Linux+php+apache+oracle环境搭建之CentOS下安装Apache
-
CentOS 6.3下源码安装LAMP(Linux+Apache+Mysql+Php)运行环境步骤
-
Linux系统下安装ccze小工具美化系统日志
-
Linux- Apache-日志分割技术(rotatelogs和cronolog 工具)及Awstats日志分析系统(解决生产查看日志错误难题,理论加实验)
-
Linux下apache日志分析与状态查看方法