wget http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE9.tar.gz useradd squid groudadd squid tar zxvf squid-3.0.STABLE9.tar.gz cd squid-3.0.STABLE9 ./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/
vi squid.conf
visible_hostname www.test.com #设置squid主机名称 http_port 80 vhost vport #squid监听80端口 cache_mem 512 MB #设置缓存内存值 maximum_object_size_in_memory 2048 KB #装入内存的文件大小 minimum_object_size 0 KB #允许最小文件请求 maximum_object_size 32768 KB #允许最大文件请求 memory_replacement_policy lru cache_dir ufs /tmp 512 16 256 #设置缓存目录大小为512MB 一级目录为16个二级目录为256个 max_open_disk_fds 0 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 192.168.0.1 parent 81 0 no-query no-digest originserver name=www #192.168.0.1为web的ip地址,81为web监听端口 cache_peer_domain www www.yemaosheng.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 #禁止缓存php cgi avi...exe一类的文件 cache_effective_user squid cache_effective_group squid #squid使用的用户名和组名 |
squid启动
/usr/local/squid/sbin/squid -s
nginx相应配置
server { listen 81; server_name www.yemaosheng.com; index index.html index.htm index.php; root /data/htdocs/www; location ~ .*\.(php|php5)?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fcgi.conf; } } |