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

在linux下安装squid服务

一.安装squid服务.
tar xzvf squid-2.6.STABLE9.tar.gz

cd squid-2.6.STABLE9

ulimit -n 65535 //打开文件数为65536
./configure --prefix=/opt/bokee/squid --enable-snmp --enable-storeio=diskd,ufs --enable-poll
--disable-hostname-checks --enable-underscores --enable-x-accelerator-vary
--enable-kill-parent-hack --enable-err-language="Simplify_Chinese"
--enable-default-err-languages="Simplify_Chinese" --disable-ident-lookups
--with-maxfd=65535;
make;
make install;
--prefix=/opt/bokee/squid :指定软件的安装路径.
--enable-snmp :此选项可以让MRTG使用SNMP协议对服务器的流量状态进行监测,因此必须选择此项,使Squid支持SNMP接口。
--enable-storeio=diskd,ufs :磁盘ache的模式.
--enable-poll :应启用Poll()函数而不是select()函数,通常而言poll(轮询)比select要好,
但configure(脚本程序)已知Poll在某些平台下失效, 若你认为你比configure编译配置脚本程序要聪明的话,
可以用这个选项启用Poll。总之就是用这个可以提升性能就是啦。
--disable-hostname-checks :关闭hostname检查;以提高速度.
--enable-underscore :允许解析的URL中出现下划先,因为默认squid会认为带下划线的URL地址是非法的,并拒绝访问该地址。
--enable-x-accelerator-vary :Enable support for the X-Accelerator-Vary
HTTP header. Can be used to indicate
variance within an accelerator setup.
Typically used together with other code
that adds custom HTTP headers to the requests.
--enable-kill-parent-hack :关掉suqid的时候,要不要连同父进程一起关掉.
--enable-err-language="Simplify_Chinese" 和
--enable-default-err-languages="Simplify_Chinese" :指定出错是显示的错误页面为简体中文.
--disable-ident-lookups :防止系统使用RFC931规定的身份识别方法。 --enable-cahce-digests :加快请求时,检索缓存内容的速度。(在squid集群时才有用)
--enable-linux-netfilter :可以支持透明代理for linux2.4.
--enable-arp-acl :可以在规则设置中直接通过客户端的MAC地址进行管理,防止客户使用IP欺骗。(和上一行配合用;只有反向代理时没用).
--with-maxfd=65535 //打开文件数为65536

二.初始化cahe磁盘目录

mkdir /opt/bokee/squid/cache

chown -R nobody:nobody /opt/bokee/squid/cache

/opt/bokee/squid/sbin/squid -z

三启动squid服务.

vi /etc/hosts
(单个域名就不用加了;直接在squid.conf中127.0.0.1用ip地址而不用virtual)

加上127.0.0.1 localhost.localdomain localhost
*.*.*.* botu.bokee.com botu.blogchina.com /opt/bokee/squid/sbin/squid -CD

./squid -k reconfigure(不重启squid服务而使squid.conf重新生效)

四.停止squid服务.

killall squid

五.进程检查

ps -ef|grep squid

六.端口检查

netstat -alp|grep squid

telnet 192.168.2.3 80

GET / HTTP/1.1

再敲回车健;有信息就代表通了.

七.查看日志.

日志记录了客户的ip地址,使用的协议,获得的目的地IP地址和所获得的内容.access.log文件是比较重要的日志文件,记录了代理服务的日常活动,可以通过一些软件,很容易对代理服务的活动信息加以统计,及查找不安全信息.
而cache.log则是缓冲区的相关记录,store.log记录了服务器访问的网页状态信息.相对而言access.log日志是使用较多的日志文件.

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