Awstat配置和日誌統計

1.首先安裝awstats

 cd /data0/software
 wget http://sourceforge.net/projects/awstats/files/AWStats/6.9/awstats-6.9.tar.gz/download
tar zxvf awstats-6.9.tar.gz
#mv /data0/software/awstats-6.9/* /usr/local/awstats
#cd /usr/local/awstats/tools
#./awstats_configure.pl
 
安裝過程中會讓你回答下列等問題
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):
> /opt/apache/conf/httpd.conf
 
Do you want me to setup Apache to write ‘combined’ log files [y/N] ? y
 
Do you want me to build a new AWStats config/profile file (required if first install) [y/N] ? y
 
Your web site, virtual server or profile name:
> redis.spy.com
 
Directory path to store config file(s) (Enter for default):
 
安裝過程會自動在httpd.conf文件中添加下面的配置信息
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/"
 
<Directory "/usr/local/awstats/wwwroot">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
 
修改主機配置文件/etc/awstats/awstats.redis.spy.com.conf,重點檢查LogFile、LogType、LogFormat、 SiteDomainin、HostAlias,把LogFile重新定義所要統計的日誌文件的路徑
/usr/local/apache/logs/redis_access_log
 
創建/var/lib/awstats創建數據庫存放目錄,並更新數據庫:
# mkdir -p /var/lib/awstats
perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update-config=redis.spy.com
 
修改/usr/local/apache/conf/httpd.conf配置文件
CustomLog
/usr/local/apache/logs/redis_access_log combined
 
2.日誌統計
統計主機日誌
# cd /usr/local/awstats/wwwroot/cgi-bin/
# perl awstats.pl -config=redis.spy.com -update -lang=cn
 
定時統計主機日誌
#update awstats
5 * * * * root perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update-config=redis.spy.com
 
重啓apache服務測試
 
如果未對awstats設置訪問控制時,訪問awstats頁面並不需要提供帳號和密碼,只要知道對應的網址就可查看web日誌的內容,這給服務器的安全帶來了隱患,因此需要對其行進訪問控制。接下來就對awstats頁面進行基於用戶的訪問控制:
創建密碼文件,cd /usr/local/awstats  
touch .htpasswd
編輯httpd.conf配置文件,在awstats的目錄區域設置,添加認證授權設置:
<Directory "/usr/local/awstats/wwwroot">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthName "AWSTATS"
    AuthType Basic
    AuthUserFile /usr/local/awstats/.htpasswd
    require valid-user
</Directory>
 
創建存儲認證用戶賬號及口令的文件
./htpasswd -c /usr/local/awstats/.htpasswd shipeiyu
按要求輸入密碼
 
重啓apache服務
/usr/local/apache/bin/httpd -k restart
登錄,彈出帳號密碼框,成功。
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章