原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://nolinux.blog.51cto.com/4824967/1318052
CentOS 6.4 x86_64 ip:192.168.1.113 站点1:域名www.sunsky.com(server和client都通过hosts文件解析) 站点2:域名www.skysun.com(server和client都通过hosts文件解析) apache-2.2.25 编译安装,路径/usr/local/apache,服务开启状态 日志记录格式为apache默认的combined格式,切勿更改,否则会造成awstats无法分析日志。 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined apr-1.4.8 apr-util-1.5.2 awstats-7.2.tar.gz
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
www.sunsky.com CustomLog "|/usr/local/sbin/cronolog /app/logs/sunsky_access_%Y%m%d.log" combined ErrorLog "|/usr/local/sbin/cronolog /app/logs/sunsky_error_%Y%m%d.log" www.skysun.com CustomLog "|/usr/local/sbin/cronolog /app/logs/skysun_access_%Y%m%d.log" combined ErrorLog "|/usr/local/sbin/cronolog /app/logs/skysun_error_%Y%m%d.log"
wget http://awstats.sourceforge.net/files/awstats-7.2.tar.gz tar zxf awstats-7.2.tar.gz mv awstats-7.2 /usr/local/awstats
chown -R root.root /usr/local/awstats chmod +x /usr/local/awstats/tools/*.pl chmod +x /usr/local/awstats/wwwroot/cgi-bin/*.pl
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... #提示配置文件创建完成和如何更新配置及建立静态报告页,这里我们回车即可结束这个配置向导
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
sed -i 's#DirData="/var/lib/awstats"#DirData="/usr/local/awstats/data"#g' /etc/awstats/awstats.www.sunsky.com.conf
grep "LogFile=" /etc/awstats/awstats.www.sunsky.com.conf grep "DirData=" /etc/awstats/awstats.www.sunsky.com.conf
mkdir /usr/local/awstats/data
chown -R daemon /usr/local/awstats
vim /server/scripts/awstats_up.sh #!/bin/sh /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.sunsky.com >/dev/null 2>&1 /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.skysun.com >/dev/null 2>&1
/usr/local/awstats/tools/awstats_updateall.pl now
/bin/sh /server/scripts/awstats_up .sh
vim /usr/local/awstats/wwwroot/cgi-bin/plugins/qqwry.pl #my $ipfile="./QQWry.Dat";
my $ipfile="${DIR}/plugins/QQWry.Dat";
sed -i 's#\#LoadPlugin="hostinfo"#LoadPlugin="qqhostinfo"#g' /etc/awstats/awstats.www.sunsky.com.conf sed -i 's#\#LoadPlugin="hostinfo"#LoadPlugin="qqhostinfo"#g' /etc/awstats/awstats.www.skysun.com.conf
grep "LoadPlugin=\"qqhostinfo\"" /etc/awstats/awstats.www.sunsky.com.conf
# # 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. # <Directory "/usr/local/awstats/wwwroot"> Options None AllowOverride None Order allow,deny Allow from all </Directory>
vim /usr/local/apache/httpd/extra/httpd-vhosts.conf
auth_basic "Restricted"; auth_basic_user_file /usr/local/nginx/htpasswd.pass;
<VirtualHost *:80> ServerAdmin webmaster@dummy-host.example.com DocumentRoot "/www/sunsky" ServerName dummy-host.example.com ServerAlias www.sunsky.com CustomLog "|/usr/local/sbin/cronolog /app/logs/sunsky_access_%Y%m%d.log" combined ErrorLog "|/usr/local/sbin/cronolog /app/logs/sunsky_error_%Y%m%d.log" auth_basic "Restricted"; auth_basic_user_file /usr/local/apache/htpasswd.pass; </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "/www/skysun" ServerName www.skysun.com CustomLog "|/usr/local/sbin/cronolog /app/logs/skysun_access_%Y%m%d.log" combined ErrorLog "|/usr/local/sbin/cronolog /app/logs/skysun_error_%Y%m%d.log" auth_basic "Restricted"; auth_basic_user_file /usr/local/apache/htpasswd.pass; </VirtualHost>
htpasswd -c -m /usr/local/nginx/htpasswd.pass admin #用户名为admin,回车之后输入两次密码即完成创建
http://www.sunsky.com/awstats/awstats.pl?config=www.sunsky.com http://www.skysun.com/awstats/awstats.pl?config=www.skysun.com
0 1 * * * /bin/sh /server/scripts/awstats_up.sh >/dev/null 2>&1
转自:http://nolinux.blog.51cto.com/4824967/1318052
原创文章,作者:s19930811,如若转载,请注明出处:http://www.178linux.com/2018