cd /server/tools/
wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
tar zxf cronolog-1.6.2.tar.gz
cd cronolog-1.6.2
./configure
make&&make install 2、配置apache使用cronolog
由于实验用的apache开启了虚拟主机功能,所以以下配置都在虚拟主机中进行,这样也是为了方便对多站点的分析操作。
vim /usr/local/apache/httpd/extra/httpd-vhosts.conf
将配置文件中的CustomLog和ErrorLog替换为下面的(由于我们要对多站点,所以这里要替换两个虚拟主机的,并且将日志存放名字做有效的区分才好)
cd /usr/local/awstats/tools/
./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
Enter full 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):
> /usr/local/apache/conf/httpd.conf #有可能是新版本的原因,这里会自动找到apache的配置文件,无需我们再自己填了,不过会问你一次,你回答y即可
Your web server config file(s) could not be found.
You will need to setup your web server manually to declare AWStats
script as a CGI, if you want to build 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 a new AWStats config/profile
file (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
Your web site, virtual server or profile name:
> www.sunsky.com #这里让填写你的网站域名,虚拟主机名或者随便一个配置名
-----> 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):
> #这里要填写你配置文件存放路径,我们使用它默认的路径/etc/awstats,所以直接回车即可
-----> Create config file '/etc/awstats/awstats.www.sunsky.com.conf'
Config file /etc/awstats/awstats.www.sunsky.com.conf created.
-----> 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.sunsky.com
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... #提示不能自动加入crontab定时任务,需要稍后自己添加,我们按回车继续即可
A SIMPLE config file has been created: /etc/awstats/awstats.www.sunsky.com.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'www.sunsky.com' with command:
> perl awstats.pl -update -config=www.sunsky.com
You can also build static report pages for 'www.sunsky.com' with command:
> perl awstats.pl -output=pagetype -config=www.sunsky.com
Press ENTER to finish... #提示配置文件创建完成和如何更新配置及建立静态报告页,这里我们回车即可结束这个配置向导 结束这个向导以后,我们对www.sunsky.com站点的awstats配置文件已经配置好了,下面配置www.skysun.com的配置文件,步骤和上面一样,只是在域名的地方做更改即可。 2、修改awstats配置文件
完成配置文件的创建之后,我们还需要对/etc/awstats/awstats.www.sunsky.com.conf里的一些参数进行修改。
sed -i 's#LogFile="/var/log/httpd/mylog.log"#LogFile="/app/logs/sunsky_access_%YYYY-24%MM-24%DD-24.log"#g' /etc/awstats/awstats.www.sunsky.com.conf 这里更改的目的是指定awstats需要分析的nginx的日志文件路径。这里的路径大家要按自己的日志路径来填。
sed -i 's#DirData="/var/lib/awstats"#DirData="/usr/local/awstats/data"#g' /etc/awstats/awstats.www.sunsky.com.conf
这里更改的目的是指定awstats的数据库配置文件(即awstats的数据库(纯文本))。
以上的两个替换操作进行完之后一定要用命令查看替换是否成功,以便及早发现纰漏。
#
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/local/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"
#
# This is to permit URL access to scripts/files in AWStats directory.
#
Options None
AllowOverride None
Order allow,deny
Allow from all
我们可以看到awstats已经在apache的主配置文件配置好了需要的参数,是不是很方便啊。此时我们还需要在配置虚拟目录配置文件里面配置几个参数来实现站点的统计信息安全。
vim /usr/local/apache/httpd/extra/httpd-vhosts.conf 添加以下两行参数进去
auth_basic "Restricted";
auth_basic_user_file /usr/local/nginx/htpasswd.pass; 添加之后的文件信息