1. 检查squid是否安装
rpm -qa | grep squid
2. 用yum安装squid
yum -y install squid
3. 配置缓存目录
编辑/etc/squid/squid.conf文件
取消cache_dir ufs /var/spool/squid 100 16 256行的注释
添加一行:cache_mem 64 MB
4. 配置反向代理
编辑/etc/squid/squid.conf文件
修改http_port 3128行:http_port 80 accel vhost
注释掉所有http_access行,在之下添加一行:http_access allow all
在之下添加一行:cache_peer xxx.xxx.xxx.xxx parent 80 0 originserver round-robin weight=1
其中xxx.xxx.xxx.xxx是web服务器地址,80是端口
还可以添加多个web服务器,但IP地址不能相同
之下添加一行:visible_hostname
www.baidu.com(地址随意填)
之下添加一行:cache_mgr xxx@mail.com(管理员的邮箱)
5. 启动squid
/etc/init.d/squid start
6. 设置防火墙允许80端口访问
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/etc/init.d/iptables save
/etc/init.d/iptables restart