Chinaunix首页 | 论坛 | 博客
  • 博客访问: 65932
  • 博文数量: 20
  • 博客积分: 2510
  • 博客等级: 少校
  • 技术积分: 240
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-07 15:19
文章分类
文章存档

2009年(3)

2008年(17)

我的朋友

分类: LINUX

2008-11-12 15:11:07

如果公司网站的图片非常多,公司内部又使用了内部DNS的话,为了加快游览公司网站,你可以在内部搭建台SQUID服务器,以加快速度。
 
------------安装--------------
cd /usr/local/src
tar zxvf squid-2.5.STABLE12.tar.gz
cd squid-2.5.STABLE12
./configure --prefix=/usr/local/squid --disable-internal-dns
make all
make install
chmod -R 777 /usr/local/squid
cd /usr/local/squid/etc/
mv squid.conf squid.conf.source
 

vi /usr/local/squid/etc/squid.conf
# visible name
visible_hostname squid.liba.com
cache_mgr
# cache config: space use 16G and memory use 512M
cache_dir ufs /cache 12000 32 64
cache_mem 512 MB
cache_effective_user nobody
cache_effective_group nobody
#
icp_port 0
http_port 80
httpd_accel_host virtual
httpd_accel_single_host off
httpd_accel_port 80
httpd_accel_uses_host_header on
httpd_accel_with_proxy on
# accelerater my domain only
# acl acceleratedHostA dstdomain .liba.com
# accelerater http protocol on port 80
acl acceleratedProtocol protocol HTTP
acl acceleratedPort port 80
# access arc
acl all src 0.0.0.0/0.0.0.0
# Allow requests when they are to the accelerated machine AND to the
# right port with right protocol
http_access allow acceleratedProtocol acceleratedPort
# acceleratedHostA
# logging
emulate_httpd_log on
cache_store_log none
cache_access_log none
cache_log none
# manager
acl manager proto cache_object
http_access allow manager all
cachemgr_passwd pass all
#addon
request_header_max_size 40 KB
maximum_object_size 40960 KB
refresh_pattern . 0 20% 360
request_timeout 60 seconds
persistent_request_timeout 60 seconds
 
把你公司的网站图片服务器地址与对应的域名全部添加到hosts文件中
如:echo "x.x.x.x x.x.com" >> /etc/hosts
 
mkdir /cache
chmod -R 777 /cache
 
echo "/usr/local/squid/sbin/squid -z " >> /etc/rc.local
echo "/usr/local/squid/sbin/squid -D " >> /etc/rc.local
 
echo "# reboot Squid cache" >>/root/restart_squid.sh
echo "killall -9 squid" >>/root/restart_squid.sh
echo "rm -rf /cache/* " >>/root/restart_squid.sh
echo "rm -f /usr/local/squid/var/logs/squid.pid " >>/root/restart_squid.sh
echo "/usr/local/squid/sbin/squid -z " >>/root/restart_squid.sh
echo "/usr/local/squid/sbin/squid -D " >>/root/restart_squid.sh
echo "# /usr/local/squid/sbin/squid -k reconfigure " >>/root/restart_squid.sh
 
chmod 777 -R /root/restart_squid.sh (可执行文件,方便以后使用)
 
crontab -l
30 4 * * * /root/restart_squid.sh
 
service iptables stop(关闭防火墙)
iptables -L(查看防火墙是否开启)
 
du -sh /cache查看cache (里面容量数值有变化,说明SQUID运作正常)
/usr/local/squid/sbin/squid -k reconfigure 刷新
阅读(1121) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~