squid3.0缓存服务器编译安装
2012-08-14 14:28 游乐场123 阅读(263) 评论(0) 编辑 收藏 举报squid的官方站点http://www.squid-cache.org/下载最新发布版本
#tar zxvf squid-3.0.STABLE13.tar.gz
#cd squid-3.0.STABLE13
./configure –prefix=/usr/local/squid –enable-dlmalloc –enable-debug-cbdata –enable-async-io=100 –with-pthreads–enable-storeio=”aufs,coss,diskd,ufs” –enable-removal-policies=”heap,lru” –enable-icmp –enable-delay-pools –enable-useragent-log –enable-referer-log –disable-wccp –disable-wccpv2 –enable-kill-parent-hack –enable-arp-acl –enable-snmp –enable-default-err-language=Simplify_Chinese –enable-err-languages=”Simplify_Chinese English” –disable-poll –enable-epoll –disable-ident-lookups –disable-internal-dns –enable-truncate –enable-underscores –enable-basic-auth-helpers=”NCSA” –enable-stacktrace –with-winbind-auth-challenge –enable-large-cache-files –with-large-files –enable-x-accelerator-vary
#make
#make install
chmod -R 777 cache目录
chmod -R 777 /usr/local/squid/var/
创建缓存目录
/usr/local/squid/sbin/squid -z
测试Squid运行状况
/usr/local/squid3/sbin/squid –NCd1
成功后将出现”Ready to serve requests”.否则请检查配置文件”
配置文件(仅供参考)
visible_hostname qksquid.duxiu.com
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localnet
http_access allow all
icp_access allow localnet
icp_access deny all
htcp_access allow localnet
htcp_access deny all
http_port 3128 vhost vport
#设定squid为accel加速模式,vhost必须要加.否则将无法将主机头转发至后端服务器,访问时就会出现无法找到主机头的错误
cache_peer 124.42.15.26 parent 80 0 no-query originserver no-digest forceddomain=jour.duxiu.com name=jour
cache_peer_domain jour 124.42.15.26
hierarchy_stoplist cgi-bin ?
access_log /usr/local/squid/var/logs/access.log squid
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern (cgi-bin|\?) 0 0% 0
refresh_pattern . 0 20% 4320
#icp_port 提供从相邻的squid查询端口,如果不提供该服务,可一将端口改为0
icp_port 3130
coredump_dir /usr/local/squid/var/cache
logformat squid %ts.%03tu %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mt
cache_store_log none
#以下定义的是不被缓存的对象
acl QUERY urlpath_regex cgi-bin .php .cgi .jsp
cache deny QUERY
#squid提供服务时所用内存
cache_mem 256 MB
#最大内存缓存OBJECT值~如果超过则不再内存中缓存~而存入IO中!
maximum_object_size_in_memory 512 KB
#替换机制
memory_replacement_policy lru
cache_dir aufs /mnt/http/cache/ 10240 32 64
max_open_disk_fds 0
minimum_object_size 0 KB
maximum_object_size 4096 KB
refresh_pattern -i .html 1440 100% 129600 override-expire reload-into-ims
refresh_pattern -i .shtml 1440 100% 129600 override-expire reload-into-ims
refresh_pattern -i .htm 1440 100% 129600 override-expire reload-into-ims
refresh_pattern -i .gif 1440 100% 129600 override-expire reload-into-ims
refresh_pattern -i .swf 1440 100% 129600 override-expire reload-into-ims
refresh_pattern -i .png 1440 100% 129600 override-expire reload-into-ims
refresh_pattern -i .bmp 1440 100% 129600 override-expire reload-into-ims
refresh_pattern -i .js 1440 100% 129600 override-expire reload-into-ims
cache_mgr yongdong@ssreader.com
error_directory /usr/local/squid/share/errors/Simplify_Chinese
修改配置文件后,重启调用
#/usr/local/squid/sbin/squid -k reconfigure