原創作品,允許轉載,轉載時請務必以超鏈接形式標明文章 原始出處 、作者信息和本聲明。否則將追究法律責任。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.www58058.com/2018