一、安装相关软件
yum install gcc* gd gd-devel kdevelop gcc-c++ -y
yum install pcre-devel
二、编译安装sarg
cd /usr/local/src
wget http://nchc.dl.sourceforge.net/project/sarg/sarg/sarg-2.3.5/sarg-2.3.5.tar.gz
tar sarg-2.3.5.tar.gz
cd sarg-2.3.5
./configure --prefix=/usr/local/sarg
make
make install
三、配置sarg
vi /usr/local/sarg/etc/sarg.conf
access_log /var/log/squid/access.log
language English
font_face Verdana,Arial
header_color darkblue
font_size 12px
title "Squid user Access reports"
output_dir /var/www/html/sarg/
overwrite_report no
mail_utility mail
topsites_num 100
exclude_codes /usr/local/etc/exclude_codes
max_elapsed 28800000
charset UTF-8
topuser_sort_field connect reverse bytes reverse
user_sort_field connect reverse BYTES reverse
exclude_users /usr/local/sarg/etc/nousers
exclude_hosts /usr/local/sarg/etc/norecords
usertab /usr/local/sarg/etc/user_ip
resolve_ip no
user_ip no
weekdays 0-6
hours 9-12,13-23
四、修改httpd配置
vi /etc/httpd/conf.d/http-vhost.conf
<Directory "/var/www/html/sarg">
AllowOverride authconfig
Order allow,deny
Allow from all
</Directory>
service httpd restart
vi /var/www/html/sarg/.htaccess
AuthType Basic
AuthName "请输入用户名和密码"
AuthUserFile /etc/user
Require valid-user
/usr/local/sarg/bin/sarg
设置访问sarg的用户
第一次
htpasswd -c /etc/setuser administrator
以后修改密码
htpasswd -m /etc/setuser administrator
网址:
http://网址/sarg