1、squid 安装
- wget http://www.squid-cache.org/Versions/v3/3.1/squid-3.1.18-20111219-r10418.tar.gz
- tar xvf squid-3.1.18-20111219-r10418.tar.gz
- cd squid-3.1.18-20111219-r10418
- ./configure --prefix=/usr/local/squid \
- --enable-epoll \
- --disable-internal-dns \
- --enable-storeio=aufs,diskd,ufs \
- --enable-default-err-languages=Simplify_Chinese \
- --enable-linux-netfilter \
- --enable-err-language=Simplify_Chinese \
- --enable-default-err-languages=Simplify_Chinese \
- --enable-arp-acl \
- --enable-snmp \
- --enable-async-io=90 \
- --enable-cahce-digests \
- --enable-underscore \
- --enable-gnuregex \
- --enable-icmp \
- --enable-kill-parent-hack \
- make&&make install
- groupadd squid
- useradd -g squid:squid squid
- mkdir -p /data/squid/logs
- chown -R squid /data/squid/
- chown -R squid /usr/local/squid
注: 1>--enable-epoll //支持epoll非阻塞io模型
2>--enable-default-err-languages=Simplify_Chinese //默认的错误语言
3>--enable-err-language=Simplify_Chinese //支持错误代理
4>--enable-arp-acl //允许基于MAC地址的存取过滤
5>--enable-snmp //支持snmp
6>--enable-async-io=90 //采用同步io提高性能,此值视具体配置情况而定
7>--enable-cahce-digests //允许缓存摘要,可以加快请求缓冲内容的速度(集群用)
8>--enable-icmp //icmp协议代理(默认不允许)
9>--enable-linux-netfilter //要想实现透明代理,启用linux netfilter支持
10>--enable-async-io=180 //1G内存,并且是双核的选180,否则选100以下
squid配置
- ###########################squid.conf#######################
- http_port 192.168.0.1:3128 transparent
- cache_mem 100 MB
- maximum_object_size 9000 KB
- maximum_object_size_in_memory 6128 KB
- #dns_nameservers 202.106.0.20 8.8.8.8
- cache_dir ufs /data/squid/cache 100 16 256
- error_directory /usr/local/squid/share/errors/zh-cn
- acl nocache urlpath_regex cookie.*\.php *\.jsp *\.asp *\.pl *\.cgi
- no_cache deny nocache
- acl audio urlpath_regex -i .torrent$ .avi$ .mp3$ .mp4$
- http_access deny audio
- acl name url_regex -i
- http_access deny name
- cache_access_log /data/squid/logs/cache_access.log
- cache_log /data/squid/logs/cache.log
- cache_store_log /data/squid/logs/cache_store.log
- acl localhost src 192.168.0.0/24
- http_access allow localhost
- #acl all src 0.0.0.0/0.0.0.0
- http_access deny all
- acl safe port 80 21 443 3128
- http_access allow safe
- cache_effective_user squid
- cache_effective_group squid
- cache_mgr 103194669@qq.com
- acl conncount maxconn 20
- visible_hostname LinuxProxyServer
- icon_directory /usr/local/squid/share/icons
- ipcache_size 2024
- ipcache_low 90
- ipcache_high 95
- fqdncache_size 2024
- #######################squid.conf_END#########################
配置文件是自己情况而定
- /usr/local/squid/sbin/squid -z 生成缓存目录
- /usr/local/sbin/squid -NCd1 显示日志运行
- /usr/local/sbin/squid 后台运行
- echo "/usr/local/sbin/squid" >> /etc/rc.local
