您的位置:首页 > 运维架构 > 反向代理

squid使用手册第一章 squid的安装

2012-03-16 16:17 267 查看
squid的作用

squid是代理服务器软件,

例如在办公室里50人都喜欢看同一个网站,那么只要有一个人看过,

其他49人再看的时候就是从proxy server那儿取数据而不需要重新

在那个网站下载了,加快下次访问速度。

现在的绝大部分站点都是用程序生成动态内容,没有缓存的话即使程序的效率再高也很难满足大访问量的需求,而且让程序不停的去做同一件事情也实在没有意义。首先,Web程序是需要做缓存处理的,即把反复使用的数据做缓存。即使这样也还不够,单单是启动Web处理程序的代价就不少,缓存最后生成的静态页面是必不可少的。而做这个是
Squid的强项,它本是做代理的,支持高效的缓存,可以用来给站点做反向代理加速。把Squid放在Apache或者Lighttpd的前端来缓存 Web服务器生成的动态内容,而Web应用程序只需要适当地设置页面实效时间即可。

squid is a high-performance proxy caching server for web clients, supporting FTP, gopher, and HTTP data objects. Unlike traditional caching software, squid handles all requests in a single, non-blocking, I/O-driven process.squid keeps meta data and especially
hot objects cached in RAM, caches DNS lookups, supports non-blocking DNS lookups, and implements negative caching of failed requests.squid supports SSL, extensive access controls, and full request logging. By using the lightweight Internet Cache Protocol,
squid caches can be arranged in a hierarchy or mesh for additional bandwidth savings.squid consists of a main server program squid, a Domain Name System lookup program dnsserver, some optional programs for rewriting requests and performing authentication,
and some management and client tools. When squid starts up, it spawns a configurable number of dnsserver processes, each of which can perform a single, blocking Domain Name System (DNS) lookup. This reduces the amount of time the cache waits for DNS lookups.

编译方式安装squid

下载

#wget http://www.squid-cache.org/Versions/v3/3.1/squid-3.1.19.tar.gz

解压缩

#tar -zxvfsquid-3.1.19.tar.gz



#cd squid-3.1.19

编译配置

#./configure --prefix=/usr/local/squid --localstatedir=/var/log/squid1 --enable-gnuregex --enable-icmp --enable-kill-parent-hack --enable-snmp --disable-ident-lookups --enable-cahce-digests --enable-arp-acl
--enable-default-err-languages="Simplify_Chinese" --enable-linux-netfilter --enable-auth-modules --enable-follow-x-forwarded-for --enable-storeio=aufs,ufs --with-maxfd=65536 --with-pthreads --enable-dlmalloc --enable-poll --enable-underscore --enable-stacktraces
--enable-removal-policies=heap,lru --enable-delay-pools --with-large-files --sysconfdir=/etc/squid --enable-snmp

make && make install

参数详解:

--prefix=/usr/local/squid \安装路径(注意因我的机器装有两种版本,所以命名不一样)

--localstatedir=/var/log/squid \日志文件的安装路径

--sysconfdir=/etc \配置文件的安装路径

--enable-gnuregex \ :由于Squid大量使用字符串处理做各种判断,加入此项能更好的处理。

--enable-icmp \加入icmp支持

--enable-kill-parent-hack \:关掉suqid的时候,要不要连同父进程一起关掉,这个当然要啦

--enable-snmp \:此选项可以让MRTG使用SNMP协议对服务器的流量状态进行监测,因此必须选择此项,使Squid支持SNMP接口。

--disable-ident-lookups \:防止系统使用RFC931规定的身份识别方法。

--enable-cahce-digests \:加快请求时,检索缓存内容的速度。

--enable-arp-acl \:可以在规则设置中直接通过客户端的MAC地址进行管理,防止客户使用IP欺骗

--enable-default-err-languages="Simplify_Chinese" \ :指定出错是显示的错误页面为简体中文

--enable-linux-netfilter \:可以支持透明代理

--enable-auth-modules此编译选项启用认证模块,可以对访问代理用户进行授权

--enable-follow-x-forwarded-for \

--enable-storeio=aufs,ufs \(支持的存储模块)

--with-maxfd=65536 \参数是增大squid文件描述符到65536

--with-pthreads \

--enable-dlmalloc \

--enable-poll \应启用Poll()函数而不是select()函数,通常而言poll(轮询)比select要好,但configure(脚本程序)已知Poll在某些平台下失效,若你认为你比configure编译配置脚本程序要聪明的话,可以用这个选项启用Poll。总之就是用这个可以提升性能就是啦。

--enable-underscore \ :允许解析的URL中出现下划先,因为默认squid会认为带下划线的URL地址是非法的,并拒绝访问该地址。

--enable-stacktraces \

--enable-removal-policies=heap,lru \

--enable-delay-pools \此选项使能一个延时池,这样能对某些特定的请求限制额定带宽。

会出现的错误提示1

checking whether the C++ compiler works... no

configure: error: no acceptable C compiler found in $PATH

解决方法:

yum install gcc gcc-c++ gcc-g77

提示:装完之后最好重启一下服务器

会出现的错误提示2

configure: WARNING: Missing needed capabilities (libcap or libcap2) for TPROXY

configure: WARNING: Linux Transparent Proxy support WILL NOT be enabled

configure: WARNING: Reduced support to Interception Proxy

configure: WARNING: Missing needed capabilities (libcap or libcap2) for TPROXY v2

configure: WARNING: Linux Transparent Proxy support WILL NOT be enabled


原因:

Seems I get the same Warning message as you got. From what I see it looks like they broke support for Linux transparent feature in 3.x. If you need that you might keep squid 2.X.

Also had to add : yum install libxml2-devel libcap-devel

If you want to use squid in transparent mode, look at intercept for version 3.1 – same thing!

原因是libcap版本太低了,squid3.1对透明代理(transparent)支持要求如下:

Linux Kernel 2.6.28

iptables 1.4.3

libcap-dev or libcap2-dev

libcap 2.09 or later

如果低于以上版本在配置编译时就会出现警告,即使安装上某些功能也会出现异常。只有把各版本升级到高版本之后才能正常使用。

参考URL:http://www.x83.net/install-squid-3-1-on-centos-5-x/

在centos下面使用yum来安装squid

yum install squid

启动squid

service squid start

停止squid

service squid stop
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: