rss· 投稿· 设为首页· 加入收藏· 繁體版

squid2.6安装

http://www.dzend.com/article.asp?id=190
、 下载squid 2.6版的软件
官方网址: 
到那里去下载最新版的 squid软件
将此软件包上传至 web主机。并在主机上将下载下来的软件包解压。如果你下载的 gz
包的话。就用tar    zxvf   XXXXX.gz (XXXX.gz 为你下载来的软件包名)  如果你下载的是 gz2
包。那么就用  tar    jxvf   XXXX.gz2(XXXX.gz2 为你下载来的软件包名)
2、 进入你解压出来的那个目录。然后执行编译安装
./configure  
--exec_prefix=/usr/local/squid  
--bindir=/usr/sbin  
--libexecdir=/usr/lib/squid  
--sysconfdir=/etc/squid  
--enable-poll  
--enable-snmp  
--enable-removal-policies="heap,lru"  
--enable-storeio="aufs,coss,diskd,null,ufs"  
--enable-ssl  
--with-openssl=/usr/kerberos  
--enable-delay-pools  
--enable-linux-netfilter  
--with-pthreads --enable-auth="basic"  
--with-winbind-auth-challenge  
--enable-useragent-log  
--enable-referer-log  
--disable-dependency-tracking  
--enable-cachemgr-hostname=localhost  
--disable-ident-lookups  
--enable-truncate  
--enable-underscores  
--datadir=/usr/share/squid  
--enable-basic-auth-helpers="NCSA"  
--enable-err-language="Simplify_Chinese"  
--enable-default-err-language="Simplify_Chinese"
编译完后再执行
make
make install
好了。安装完毕后,修改目录权限,默认是以"nobody"用户运行squid.所以我们要为
/usr/local/squid/var  设置相应的权限,否则会报以下错误
FATAL: Failed to make swap directory /usr/local/squid/var/cache: (13) Permission denied
Squid Cache (Version 2.5.STABLE13): Terminated abnormally.
CPU Usage: 0.000 seconds = 0.000 user + 0.000 sys
Maximum Resident Size: 0 KB
Page faults with physical i/o: 4
或者以下错误
FATAL: Cannot open '/usr/local/squid/var/logs/access.log' for writing.
         The parent directory must be writeable by the
         user 'nobody', which is the cache_effective_user
         set in squid.conf.
最简单的处理办法就是
chown -R nobody:nobody /usr/local/squid/var
ok,生成缓存目录
/usr/local/squid/sbin/squid -z
然后启动squid,测试一下是否成功
/usr/local/squid/bin/Runcache  
默认端口是3128,用ie测试一下,如果能看到中文的拒绝访问错误提示,就说明安装正确,
并且已经使用.
 
以后就可以直接/usr/local/squid/bin/Runcache   &  后台运行即可,  
现在我们开始讲如何配置 squid.conf 文件
visible_hostname localhost #你的主机名可以是localhost
http_port 211.XX.XX.XXX:80 vhost vport #你需要做 squid服务器的IP及端口号
icp_port 0
cache_mem 900 MB #squid  所使用的内存
cache_swap_low 90 #缓存最低使用
cache_swap_high 95 #缓存最高使用
maximum_object_size 20000 KB #当大于200000K 时不对文件进
maximum_object_size_in_memory 4096 KB #放入内存的最小大小
cache_dir ufs /dev/shm/tmp 1000 16 256 #这里我们会在后面再讲
  
cache_store_log none
cache_vary on #apache 的一个新特性。
emulate_httpd_log on #日志
cache_mgr tpsys@126.com #设置管理员的邮箱
logfile_rotate 0 #日志不保存
logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>h"
"%{User-Agent}>h" %Ss:%Sh #日志格式
pid_filename /home/squid/squid.pid #pid文件
cache_log /home/squid/var/logs/cache.log #日志
access_log /home/squid/var/logs/access.log combined #日志
acl all src 0.0.0.0/0.0.0.0   #允许所有地址访问
acl QUERY urlpath_regex cgi-bin .php .cgi .avi .wmv .rm .ram .mpg .mpeg .zip .exe .rar  对这一些
扩名的文件不缓存
cache deny QUERY
acl picurl url_regex -i \.bmp$ \.png$ \.jpg$ \.gif$ \.jpeg$ \.rm$ #主要是防盗连。
acl mystie1 referer_regex -i .5i.la #对5i.la防盗连
http_access allow mystie1 picurl
acl mystie3 referer_regex -i .wg333.com#对 wg333.com防盗连
http_access allow mystie3 picurl
acl mystie4 referer_regex -i .99doc.com#对99doc.com防盗连
http_access allow mystie4 picurl
acl mystie2 referer_regex -i .orasos.com#对 orasos.com防盗连
http_access allow mystie2 picurl
acl nullref referer_regex -i ^$
http_access allow nullref
acl hasref referer_regex -i .+
http_access deny hasref picurl
  
acl Safe_ports port 80 # http #  开放80端口允许进来。
acl Safe_ports port 21 # ftp #  开放21端口允许进来。
http_access deny !Safe_ports
tcp_recv_bufsize 65535 bytes
acl OverConnLimit maxconn 36   #同一个客户端最多只允许连入36 个连接
http_access deny OverConnLimit
acl tianya referer_regex -i tianya
http_access deny tianya
deny_info http://www.baidu.com/logs.gif tianya
  
refresh_pattern -i .html 1440 100% 129600 reload-into-ims   #对HTML 进行缓存
refresh_pattern -i .shtml 1440 100% 129600 reload-into-ims #对SHTML进行缓存
refresh_pattern -i .htm 1440 100% 129600 reload-into-ims #对HTM进行缓存
refresh_pattern -i .gif 1440 100% 129600 reload-into-ims #对GIF进行缓存
refresh_pattern -i .swf 1440 100% 129600 reload-into-ims #对SWF进行缓存
refresh_pattern -i .png 1440 100% 129600 reload-into-ims #对 PNG进行缓存
refresh_pattern -i .bmp 1440 100% 129600 reload-into-ims #对BMP进行缓存
refresh_pattern -i .css 1440 100% 129600 reload-into-ims#对 CSS进行缓存  
refresh_pattern -i .jpg 1440 100% 129600 reload-into-ims #对 JPG 进行缓存
refresh_pattern -i .txt 1440 100% 129600 reload-into-ims #对TXT进行缓存
refresh_pattern -i .rhtml 1440 100% 129600 reload-into-ims #对RHTML进行缓存
refresh_pattern -i .xml 1440 100% 129600 reload-into-ims #对XML进行缓存
#以下内容和squid 2.5有所不一样。2.6 中需要通过 cache_peer来设定指向主机,如果你需要
做虚拟主机的话。你可以省略 name=a  这个关建字  举例说明
cache_peer 192.168.8.105 parent 80 0 no-query originserver name=a  
#每一个name 关建字。必须要和下面的 cache_peer_domain  一起来使用。
cache_peer 192.168.8.161 parent 888 0 no-query originserver name=b
#这里的888  和  808  分别指的是你的apache  或者 IIS  绑定的主机头里的端口号。我们这里
是为了安全,所以不采用80端口
cache_peer 192.168.8.88  parent 808 0 no-query originserver name=c
#808后面的0 为 icp_port 0  这什值。我们目前用不到。所以先不管。你只要写0 就行
cache_peer_domain b .orasos.com
#比如这一句话的意思就是。当orasos.com这外域来访问 squid时。Squid通确定他使用的是
什么域名  这里使用的是 orasos.com  然后来查询 cache_peer_domain  中有没有这个域名。如
果有则取这个域名的cache_peer的name  值   我们这里是b  然后再和cache_peer中去比对。
有没有name=b这个主机指向。如果有,就从这个主机指向那里取数据
cache_peer_domain a .5i.la
cache_peer_domain a .99doc.com
cache_peer_domain a .wg333.com
cache_effective_user nobody
cache_effective_group nobody
好了。写了这么多。安装和配置就搞定了。
如果你能看的明白话。我想你装一个Squid起来的话。是绝对不会在问题了的。

顶一下
(0)
踩一下
(0)