基于Squid的反向加速多个WEB服务器[安装文档]

王朝other·作者佚名  2006-05-16
窄屏简体版  字體: |||超大  

基于Squid的反向加速多个WEB服务器

Step I - Downloading and compiling Squid

Wget http://www.squid-cache.org/Versions/v2/2.5/squid-2.5.STABLE13.tar.gz

[root@redhatas4 squid-2.5.STABLE13]# tar zxvf squid-2.5.STABLE13.tar.gz

[root@redhatas4 squid-2.5.STABLE13]# cd squid-2.5.STABLE13

[root@redhatas4 squid-2.5.STABLE13]# vi config.sh

写入内容如下:

代码:

#!/bin/bash

SQUID_ROOT="/Data/apps/squid"

./configure --prefix=$SQUID_ROOT

--enable-useragent-log

--enable-referer-log

--enable-default-err-language=Simplify_Chinese

--enable-err-languages="Simplify_Chinese English"

--disable-internal-dns

[root@redhatas4 squid-2.5.STABLE13]# sh config.sh

[root@redhatas4 squid-2.5.STABLE13]# make

[root@redhatas4 squid-2.5.STABLE13]# make install

Step II - Basic Configuration

[root@redhatas4 squid]# cd /Data/apps/squid/

[root@redhatas4 squid]# mkdir cache

[root@redhatas4 squid]# chown squid.squid *

A、 在/etc/hosts中:加入内部的DNS解析,比如:

61.135.132.176 www.sohu.com

202.108.33.32 www.sina.com

202.108.9.16 www.163.com

202.108.12.68 www.tom.com

B、vi /Data/apps/squid/etc/squid.conf

详见附件,重点都在这里了

Step III - Starting Squid

A、创建缓存目录

[root@redhatas4 sbin]# ./squid –z

B、测试Squid运行状况

[root@redhatas4 sbin]# ./ squid –NCd1

成功后将出现"Ready to serve requests".否则请检查配置文件

C、建立Squid启动脚本

# cd /etc/rc.local

#vi squid.sh

代码:

#!/bin/sh

# if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/$(basename $0)\$"); then

# echo "$0: Cannot determine the PREFIX" >&2

# exit 1

# fi

case "$1" in

start)

if [ -x /Data/apps/squid/sbin/squid -a -f /Data/apps/squid/etc/squid.conf ]; then

(cd /Data/apps/squid/var/logs; /Data/apps/squid/sbin/squid >/dev/null 2>&1 &) ; echo -n ' squid'

fi

;;

stop)

/Data/apps/squid/sbin/squid -k shutdown 2>&1

# Uncomment this if you'd like the system to (attempt to

# wait for) squid to shut down cleanly

#echo "Sleeping for 45 seconds to allow squid to shutdown.."

#sleep 45

;;

*)

echo "Usage: `basename $0` {start|stop}" >&2

;;

esac

exit 0

启动squid

/etc/rc.local/squid.sh start 启动squid

/etc/rc.d/squid.sh stop 停止squid

启用新配置:

/Data/apps/squid/sbin/squid -k reconfig

通过crontab每天0点截断/轮循日志:

0 0 * * * (/Data/apps/squid/sbin/squid -k rotate)

停止squid:

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航