squid cache 服务器端的安装,配置
一,什么squid Squid是一个高性能的代理缓存服务器,可以加快内部网浏览Internet的速度,提高客户机的访问命中率。Squid不仅支持HTTP协议,还支持FTP、gopher、SSL和WAIS等协议。和一般的代理缓存软件不同,Squid用一个单独的、非模块化的、I/O驱动的进程来处理所有的客户端请求。 Squid将数据元缓存在内存中,同时也缓存DNS查寻的结果,除此之外,它还支持非模块化的DNS查询,对失败的请求进行消极缓存。Squid支持SSL,支持访问控制。由于使用了ICP,Squid能够实现重叠的代理阵列,从而最大限度的节约带宽。 Squid能够增强访问控制,提高安全性。可以针对特定的的网站、用户、网络、数据类型实施访问控制等 二,安装squid
http://www.squid-cache.org/Versions/v3/3.1 tar zxvf squid-3.1.4.tar.gz -C? /home/zhangy cd /home/zhangy/squid-3.1.4 ./configure --prefix=/usr/local/squid make && make install 说明:安装的时候./configure提供很多的参数选择,你可以查看./configure --help来获得,部分如下 --enable-icap-client??? Enable the ICAP client. 加了很多参数,安装报错 coss/StoreFScoss.cc:1:2: error: #error COSS Support is not stable yet in Squid-3. Please do not use. 三,配置squid 当你装好后,在usr/local/squid/etc文件夹下面会有些文件,squid.conf是squid的配置文件,会产生一个配置文件的备份文件,如下图 squid安装 你可以把原来的配置文件删除掉,重新建个squid.conf,原配置文件有备份,上图中你可以看到squid.conf.default就是备份文件,squid.conf.documented这个文件,是3.14总的配置文件,有5000多行,你想的什么配置都能在里面找到。我的配置文件 # # Recommended minimum configuration: # acl manager proto cache_object acl localhost src 127.0.0.1/32 acl localhost src ::1/128 acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 acl to_localhost dst ::1/128 #自带端口设置 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 # We recommend you to use at least the following line. hierarchy_stoplist cgi-bin ? # Leave coredumps in the first cache dir coredump_dir /usr/local/squid/var/cachebak #squid监听9000端口 http_port 9000 accel vhost vport #设置缓存内存值 cache_mem 128 MB #设置内存池 memory_pools_limit 50 MB #装入内存的文件大小 maximum_object_size_in_memory 2048 KB #允许最小文件请求 minimum_object_size 0 KB #允许最大文件请求 maximum_object_size 1280 KB #设置缓存目录大小为256MB 一级目录为16个二级目录为256个 memory_replacement_policy lru cache_dir ufs /usr/local/squid/var/cache 256 16 256 max_open_disk_fds 0 #日志的格式 emulate_httpd_log on logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %>Hs % 上面的例子,只是实验用的配置,并且没有真正部署的配置 squid3.1系列官方配置说明 http://www.squid-cache.org/Versions/v3/3.1/cfgman/ squid3.0系列官方配置说明 http://www.squid-cache.org/Versions/v3/3.0/cfgman/ squid2.7系列官方配置说明 http://www.squid-cache.org/Versions/v2/2.7/cfgman/ squid2.6系列官方配置说明 http://www.squid-cache.org/Versions/v2/2.6/cfgman/ 四,生成cache目录 利用./squid -z来生成目录 cd /usr/local/squid/sbin ./squid -z 说明:如果配置不出问题的话,生成目录不会有问题,你可以用./squid -k parse来测试配置文件 以下是我遇到的问题 FATAL: Can't parse configuration token: '%>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh' Squid Cache (Version 3.1.4): Terminated abnormally. CPU Usage: 0.003 seconds = 0.000 user + 0.003 sys Maximum Resident Size: 12768 KB Page faults with physical i/o: 1 [zhangy@BlackGhost sbin]# ./squid -z 2010/06/10 22:14:08| WARNING: the "Hs" formating code is deprecated use the ">Hs" instead 2010/06/10 22:14:08| WARNING cache_mem is larger than total disk cache space! 2010/06/10 22:14:08| Creating Swap Directories 2010/06/10 22:14:08| /usr/local/squid/var/cache exists 五,squid启动 ./squid (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |