执行 tools 目录中的 awstats_configure.pl 配置向导,创建一个新的统计
cd /usr/local/awstats/tools
./awstats_configure.pl
将会有如下一些提示:
-----> Running OS detected: Linux, BSD orUnix
----->Check for web server install
Enterfull config file path of your Web server.
Example:/etc/httpd/httpd.conf
Example:/usr/local/apache2/conf/httpd.conf
Example:c:\Program files\apache group\apache\conf\httpd.conf Config file path ('none' to skip web server setup):
>none #这里添none并回车,因为我们没有使用apache
回车之后下一个选项:
Yourweb server config file(s) could not be found.
Youwill need to setup your web server manually to declare AWStats
script as a CGI, if you want tobuild reports dynamically. See AWStats setup documentation (file docs/index.html)
----->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 anew AWStats config/profilefile (required if first install) [y/N] ? y #这里选Y,创建一个新的配置文件
-----> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Yourweb site, virtual server or profile name:
>nginx #这里输入你要分析的域名,或是随便一个你易记的配置名并回车
----->Define config file path In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directorypath to store config file(s) (Enter fordefault):
> #直接回车,定义你的配置文件存放的路径,使用默认路径/etc/awstats
----->Create config file '/etc/awstats/awstats.nginx.conf'
Configfile /etc/awstats/awstats.nginx.conf created.
-----> Add updateprocess inside a scheduler Sorry, configure.pl does not support automatic addto cron yet.
You can do it manually by adding the following command to yourcron: /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=nginx
Or if you have several config files and prefer having only onecommand: /usr/local/awstats/tools/awstats_updateall.pl now
Press ENTER to continue...#按回车继续
A SIMPLE config file has been created: /etc/awstats/awstats.nginx.conf You should have a lookinside to check and change manually main parameters.
Youcan then manually update your statistics for'yuyuanchun.com' withcommand: > perl awstats.pl -update -config=nginx
Youcan also build static report pages for'nginx' with command:> perl awstats.pl -output=pagetype -config=nginx
PressENTER to finish... #回车完成配置文件的创建
默认会生成一个名为awstats.nginx.conf配置文件在/etc/awstats/目录下,修改该配置文件的日志位置
vim /etc/awstats/awstats.nginx.conf
LogFile="/usr/local/nginx/logs/access_%YYYY-0%MM-0%DD-24.log"
日志说明
# "LogFile" contains the web, ftp or mail server logfile to analyze.
#You can also use tags inthis filename if you need a dynamic file name
#depending on date or time (Replacement is made by AWStats at the beginning
# ofits 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=24if you need (1-7, 1=monday)
# %Dw-n is replaced with the day number in week (0-6, 0=sunday)
# use n=24if you need (0-6, 0=monday)
# Use 0for n if you need current year, month, day, hour...
n表示时间间隔,我这里就是分析距离当前今天24小时前(昨日)的日志,改成48就是前两天的日志
出现报错:
Fromdata in log file "/usr/local/nginx/logs/access_20131111.log"...
Error:Couldn't open server log file "/usr/local/nginx/logs/access_20131111.log" : 没有那个文件或目录
解决办法:
touch /usr/local/nginx/logs/access_20131111.log
再次执行
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=nginx
如果看到类似下面的提示就说明配置文件都正确了
Create/Updatedatabase for config "/etc/awstats/awstats.nginx.conf" by AWStats version 7.0 (build 1.964) From data
in log file "/home/wwwlogs/access.log_20130727"... Phase 1 : First bypass old records, searching new record...
Directaccess after last parsed record (after line 43260) Jumped lines in file: 43260 Found 43260 already parsed records.
Parsedlines in file: 0
Found0 dropped records,
Found0 comments,
Found0 blank records,
Found0 corrupted records,
Found0 old records,
Found0new qualified records