用squid加速apache
早就看过用squid加速apache的文章,就是懒的去玩,今天闲来郁闷,突然想玩玩,所以就有了本文(本文不算是原创,都是建立他人的基础上凑起来的,算是整理吧!)
系统:redhat as 4
apache :httpd-2.0.52-9.ent
squid :squid-2.5.STABLE6-3.4E.3
1.安装
安装squid很简单:
# yum -y install squid
配置squid
修改:/etc/squid/squid.conf成下面的
http_port 80
icp_port 0
acl QUERY urlpath_regex cgi-bin
no_cache deny QUERY
cache_mem 16 MB
cache_dir ufs /tmp 256 16 256
log_icp_queries off
buffered_logs on
emulate_httpd_log on
redirect_rewrites_host_header off
half_closed_clients off
acl all src 0.0.0.0/0.0.0.0
http_access allow all
cache_mgr admin
cache_effective_user squid
cache_effective_group squid
httpd_accel_host virtual
httpd_accel_uses_host_header on
httpd_accel_port 81
这里解释一下
http_port”参数指定Squid监听浏览器客户请求的端口号,这里当然是80了
cache_dir ufs /tmp 256 16 256
cache_dir参数设定使用的存储系统的类型。一般情况下都类型应该是ufs,目录应该是“/tmp”,在该目录下使用的缓冲值为256MB,允许在“/tmp”下创建的第一级子目录数为16,每个第一级子目录下可以创建的第二级子目录数量为256
选项“httpd_accel_host”和“httpd_accel_port”定义了真正的Web服务器的主机名和端口号。在这里的配置中,真正的HTTP服务器运行的状况是虚拟主机:virtual而运行的端口是:81。
选项“httpd_accel_uses_host_header”是什么意思就不清楚了,还没看说明
3.修改apache的配置文档
这里就不说apache的安装了!
注意3个地方:
(1)
Port 80这里改成:Port 81
(2)
NameVirtualHost 221.6.145.41:81
如何没有这句,就加上这句!
(3)虚拟主机:
<VirtualHost 221.6.145.41:81>
ServerAdmin webmaster@ourlinux.net
DocumentRoot /var/www/yum.ourlinux.net
ServerName apt.ourlinux.net
ErrorLog logs/yum.ourlinux.net-error_log
CustomLog logs/yum.ourlinux.net-access_log common
</VirtualHost>
<VirtualHost 221.6.145.41:81>
ServerAdmin webmaster@ourlinux.net
DocumentRoot /var/www/apt.ourlinux.net
ServerName apt.ourlinux.net
ErrorLog logs/yum.ourlinux.net-error_log
CustomLog logs/yum.ourlinux.net-access_log common
</VirtualHost>
ip部分要一致!
4.启动!
先启动httpd
再启动squid
From:http://zerosspaces.spaces.live.com/blog/cns!15c23b3444342fd!169.entry
版权声明:
作者:Kiyo
链接:https://www.wkiyo.cn/html/2008-01/i426.html
来源:Kiyo's space
文章版权归作者所有,未经允许请勿转载。
共有 0 条评论