./configure \
--prefix=/usr/local/squid \
--disable-internal-dns \
--enable-forward-log   \
--enable-follow-x-forwarded-for \
--enable-snmp \
--enable-linux-netfilter  \
--enable-http-violations \
--enable-delay-pools \
--enable-storeio=diskd,aufs,ufs,coss \
--with-coss-membuf-size=8388608 \
--with-large-files \
--enable-large-cache-files \
--with-maxfd=8192 \
--enable-removal-policies=lru,heap \
--enable-useragent-log \
--enable-referer-log  \
--enable-err-languages=Simplify_Chinese \
--enable-default-err-language=Simplify_Chinese
make && make install
 
mkdir /usr/local/squid/var/cache
chown -R nobody.nobody /usr/local/squid/var/cache
chown -R nobody.nobody /usr/local/squid/var/logs
 
vim /usr/local/squid/etc/squid.conf
visible_hostname zj.163.com
http_port 10.80.11.212:80 vhost vport
icp_port 0
cache_mem 1024 MB
cache_swap_low 90
cache_swap_high 95
maximum_object_size 20000 KB
maximum_object_size_in_memory 4096 KB
cache_dir ufs /usr/local/squid/var/cache 10000 16 256
ipcache_size 10240
fqdncache_size 10240
cache_store_log none
emulate_httpd_log on
logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh
pid_filename /usr/local/squid/squid.pid
cache_log /usr/local/squid/var/cache/cache.log
access_log /usr/local/squid/var/logs/access.log combined
cache_mgr yhl@zjhcsoft.com
memory_pools off
memory_pools_limit none
#local mamage
acl manager proto cache_object
acl localhost src 127.0.0.1 10.80.11.212
http_access allow manager localhost
http_access deny manager
acl all src 0.0.0.0/0.0.0.0
http_access allow all
#deny this file cache
acl QUERY urlpath_regex cgi-bin .jsp .do .php .cgi .avi .wmv .rm .ram .mpg .mpeg .zip .exe
cache deny QUERY
#acl picurl url_regex -i \.bmp$ \.png$ \.jpg$ \.gif$ \.jpeg$
#acl mystie1 referer_regex -i ct10000
#http_access allow mystie1 picurl
#acl nullref referer_regex -i ^$
#http_access allow nullref
#acl hasref referer_regex -i .+
#http_access deny hasref picurl
cache_peer 10.80.11.208 parent 80 0 no-query originserver name=web1
cache_peer_domain web1 zj.163.com
cache_effective_user nobody
cache_effective_group nobody
 
 
初始化你在 squid.conf 里配置的 cache 目录
/usr/local/squid/sbin/squid -zX
验证 squid.conf 的 语法和配置
/usr/local/squid/sbin/squid -k parse
前台启动squid,并输出启动过程
/usr/local/squid/sbin/squid -N -d1
出现2010/06/21 15:36:44| Ready to serve requests. 说明启动成功
然后 ctrl + c,停止squid,并以后台运行的方式启动它
启动squid在后台运行
/usr/local/squid/sbin/squid -s
停止 squid
/usr/local/squid/sbin/squid -k shutdown
要执行两次才能正常关闭squid
重引导修改过的 squid.conf
/usr/local/squid/sbin/squid -k reconfigure
可能通过squidclient这个工具来查看squid的运行情况,缓存命中率等
/usr/local/squid/bin/squidclient -h 10.80.11.203 -p 80 mgr:info
可查看各选项的使用说明
/usr/local/squid/bin/squidclient -h 10.80.11.203 -p 80 mgr:
内存使用情况可通过如下选项查看
/usr/local/squid/bin/squidclient -h 10.80.11.203 -p 80 mgr:mem
查看你的日志文档
more /usr/local/squid/var/logs/access.log | grep TCP_MEM_HIT
该指令可以看到在squid运行过程中,有那些文件被squid缓存到内存中,并返回给访问用户
more /usr/local/squid/var/logs/access.log | grep TCP_HIT
该指令可以看到在squid运行过程中,有那些文件被squid缓存到cache目录中,并返回给访问用户
more /usr/local/squid/var/logs/access.log | grep TCP_MISS
该指令可以看到在squid运行过程中,有那些文件没有被squid缓存,而是现重原始服务器获取并返回给访问用户