squid的安装配置:
wget http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE2.tar.gz 建议去官方下载最新版的
#useradd squid 增加用户
#groupadd squid 增加用户组
#tar zxvf squid-3.0.STABLE2.tar.gz 解压
#cd squid-3.0.STABLE2 进入目录
#./configure –prefix=/usr/local/squid –disable-carp –with-aufs-threads=32 –with-pthreads –enable-storeio=’ufs,aufs,coss,null’ –enable-disk-io=’AIO,Blocking’ –enable-removal-policies=’heap,lru’ –disable-wccp –enable-kill-parent-hack –disable-snmp –disable-poll –disable-select –enable-auth=basic –with-aio –disable-ident-lookup –with-filedescriptors=65536 编译
#make 生成
#make install 安装
可能需要创建一些文件 这些都是配置文件中需要调用的(这个要注意文件的属主和权限)
#cd /usr/local/squid/var/logs/
#touch cache.log
#chmod 755 cache.log
#chown squid:squid cache.log
#touch page_zs_access_log
#chmod 755 page_zs_access_log
#chown squid:squid page_zs_access_log
#cd /usr/local/squid/etc/
# > squid.conf
# vi squid.conf(211.**.**.**为服务器的ip地址)
visible_hostname www.abc.com
http_port 80 vhost vport
cache_mem 512 MB
maximum_object_size_in_memory 2048 KB
memory_replacement_policy lru
cache_dir ufs /tmp 512 16 256
max_open_disk_fds 0
minimum_object_size 0 KB
maximum_object_size 32768 KB
logformat combined %>a %ui %un [%tl] “%rm %ru HTTP/%rv” %Hs %<st “%{Referer}>h” “%{User-Agent}>h” %Ss:%Sh
access_log /usr/local/squid/var/logs/page_zs_access_log combined
pid_filename /usr/local/squid/var/logs/squid.pid
cache_store_log none
cache_peer 211.**.**.** parent 81 0 no-query no-digest originserver name=www
cache_peer_domain www www.abc.com
cache_peer_access www allow all
http_access allow all
acl QUERY urlpath_regex cgi-bin .php .cgi .avi .wmv .rm .ram .mpg .mpeg .zip .exe
cache deny QUERY
cache_effective_user squid
cache_effective_group squid
#/usr/local/squid/sbin/squid -k parse
可以根据这个测试命令用来验证squid.conf的语法和配置(下面是OK的如果不OK会有相应的提示根据提示来修改配置文件)
2008/03/19 15:29:48| Processing Configuration File: /usr/local/squid/etc/squid.conf (depth 0)
#/usr/local/squid/sbin/squid -z
用来Creating Swap Directories
vi一个squid.sh的启动脚本如下:赋予可执行权限
#!/bin/sh
#
ulimit -HSn 15000
# this script starts and stops Squid
echo 15000 > /proc/sys/fs/file-max
case “$1” in
start)
/usr/local/squid/sbin/squid -s
echo -n ‘ Squid’
;;
stop)
/usr/local/squid/sbin/squid -k shutdown
;;
esac
#./squid.sh start就可以启动squid了(还有测试命令如:/usr/local/squid/sbin/squid -CNd1参考下)
查看有没有启动可以
#ps fax|grep squid
13750 pts/3 S+ 0:00 \_ grep squid
30474 ? Ss 0:00 /usr/local/squid/sbin/squid -s
30476 ? S 0:01 \_ (squid) -s
则证明OK