centos + nginx + awstats

來源:互聯網
上載者:User

wget http://nchc.dl.sourceforge.net/sourceforge/awstats/awstats-6.9.tar.gz
tar zxvf awstats-6.9.tar.gz
mv awstats-6.9/ /usr/local/
cd /usr/local/awstats-6.9/tools/
./awstats_configure.pl

Do you want to continue setup from this NON standard directory [yN] ?

y

Config file path ('none' to skip web server setup):

>none

file (required if first install) [y/N] ?

y

Example: demo
Your web site, virtual server or profile name:
>test.openx.cn

-----> 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):
>Enter(安預設的,設定檔儲存在/etc/awstats)
 
 
 

vim /etc/awstats/awstats.test.openx.cn.conf

替換下面配置:
LogFile="/home/wwwlogs/access_%YYYY-24%MM-24%DD-24.log"

三,開始分析、產生結果

最後,可以執行分析了。

使用這個命令:
/usr/local/awstats-6.9/tools/wwwroot/cgi-bin/awstats.pl -update -config=test.openx.cn
 

這個命令會把結果產生到/var/lib/awstats 目錄下 awstatsXXXX.www.XXXX.com.txt檔案。

當然這樣看起來不太方便,可以再用下面的命令來產生html頁面,更加直觀。

/usr/local/awstats-6.9/tools/awstats_buildstaticpages.pl -update -config=test.openx.cn -lang=cn -dir=/data/awstats -awstatsprog=/usr/local/awstats-6.9/wwwroot/cgi-bin/awstats.pl

/usr/local/awstats-6.9/tools/awstats_buildstaticpages.pl -update \
 -config=www.xxxxoke.com -lang=cn \
-dir=/html/awstats \
-awstatsprog=/usr/local/awstats-6.9/tools/wwwroot/cgi-bin/awstats.pl

 

這樣就會在/html/awstats目錄下產生很直觀的分析結果頁。

 

四,自動化

要是每天都去伺服器上運行幾條命令肯定是件令人煩燥的事情,幸虧Linux的世界裡有crontab,

下面是從網友那找的 crontab

 

1 0 * * * sh /home/zyf/sh/cut_nginx_log.sh

0 1 * * * /usr/local/awstats-6.9/wwwroot/cgi-bin/awstats.pl -update -config=www.xxxxke.com

0 2 * * * /usr/local/awstats-6.9/tools/awstats_buildstaticpages.pl -update -config=www.xxxxke.com -lang=cn -dir=/html/awstats -awstatsprog=/usr/local/awstats-6.9/tools/wwwroot/cgi-bin/awstats.pl

LogFile="/home/wwwlogs/access_%YYYY-24%MM-24%DD-24.log"

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.