CODE:
squid-2.6.STABLE23.tar.gz
下载地址:
apache-tomcat-6.0.20-src.tar.gz
jdk-6u17-linux-x64.bin
urlrewritefilter-2.6.zip
CODE:
http://www.squid-cache.org/Versions/v2/2.6/squid-2.6.STABLE23.tar.gz
二、安装:
http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.20/src/apache-tomcat-6.0.20-src.tar.gz
http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/jdk-6u18-linux-x64.bin?BundledLineItemUUID=gvpIBe.o0B4AAAEn90tk0Tt9&OrderID=s9FIBe.oLBYAAAEn60tk0Tt9&ProductID=p_9IBe.pFJcAAAElWitRSbJV&FileName=/jdk-6u18-linux-x64.bin
http://tuckey.org/urlrewrite/dist/urlrewritefilter-2.6.zip
1、Squid:
#tar zvxf squid-2.6.STABLE23.tar.gz
#cd squid-2.6.STABLE23
#vi install.sh
CODE:
./configure \
#sh install.sh
make
make install
2、Tomcat:
#tar zvxf apache-tomcat-6.0.20-src.tar.gz
#mv apache-tomcat-6.0.20 tomcat-6.0.20
3、JDK:
#chmod u+x jdk-6u17-linux-x64.bin
#./ jdk-6u17-linux-x64.bin
安装过程需要输入yes
4、Urlrewrite:
#unzip urlrewritefilter-2.6.zip
#cp urlrewritefilter-2.6/WEB-INF/lib/urlrewrite-2.6.0.jar /usr/local/tomcat-6.0.20/webapps/ROOT/WEB-INF/lib/
#cp urlrewritefilter-2.6/WEB-INF/urlrewrite.xml /usr/local/tomcat-6.0.20/webapps/ROOT/WEB-INF
三、配置:
1、Squid:
#cd /usr/local/squid2/etc/
#vi squid.conf
CODE:
http_port 80 vhost vport
检查配置文件有没有问题
cache_peer 127.0.0.1 parent 8080 0 no-query originserver no-digest name=tomcat
cache_peer_domain tomcat tomcat.linuxtone.org
visible_hostname cache.linuxtone.org
cache_mgr hamgua@linuxtone.org
cache_effective_user squid
cache_effective_group squid
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl Safe_ports port 80
acl Safe_ports port 8080
acl SSL_ports port 443
acl CONNECT method CONNECT
http_access allow all
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny all
icp_access allow all
cache_replacement_policy lru
#cache_dir
cache_dir aufs /usr/local/squid2/cache 32768 64 64
cache_mem 2048 MB
max_open_disk_fds 0
#maximum_object_size 512 KB
#maximum_object_size_in_memory 256 KB
maximum_object_size 20 MB
maximum_object_size_in_memory 8 MB
refresh_pattern ^ftp:
refresh_pattern ^gopher:
refresh_pattern .
refresh_pattern -i /$
refresh_pattern -i .html$
refresh_pattern -i .shtml$
refresh_pattern -i .htm$
#refresh_pattern -i .jsp$
#refresh_pattern -i .[do|do\?.+]
refresh_pattern -i .css$
refresh_pattern -i .[js|js\?.+]
refresh_pattern -i \.jpg$
refresh_pattern -i \.gif$
refresh_pattern -i \.swf$
refresh_pattern -i \.jpg$
refresh_pattern -i \.png$
refresh_pattern -i \.bmp$
refresh_pattern -i \.doc$
refresh_pattern -i \.ppt$
refresh_pattern -i \.xls$
refresh_pattern -i \.pdf$
refresh_pattern -i \.rar$
refresh_pattern -i \.zip$
refresh_pattern -i \.txt$
refresh_pattern -i \.ico$
header_access Via deny all
header_access Server deny all
#header_access X-Cache deny all
#header_access X-Cache-Lookup deny all
hierarchy_stoplist cgi-bin
acl QUERY urlpath_regex cgi-bin index\.do login\.jsp logIfr\.jsp logIfr\.jsp\?logout\=1
#acl QUERY urlpath_regex cgi-bin ? \.do
cache deny QUERY
# logfile
emulate_httpd_log on
logformat combined %{X-Forwarded-For}>h %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh
#access_log none
#access_log /usr/local/squid2/var/logs/access.log combined
logformat linuxtone [%tl] %6tr %>a
access_log /usr/local/squid2/var/logs/access.log linuxtone
#cache_store_log /var/log/squid3/store.log
cache_store_log /dev/null
cache_log /usr/local/squid2/var/logs/cache.log
logfile_rotate 12
#/usr/local/squid2/sbin/squid –k parse
启动squid:
# ulimit -SHn 65535
#/usr/local/squid2/sbin/squid –s
2、Jdk:
在profile最后加入jdk变量
#vi /etc/profile
CODE:
JAVA_HOME=/usr/local/jdk1.6.0_18
让环境变量生效
PATH=/usr/local/jdk1.6.0_18/bin:$PATH
CLASSPATH=.:/usr/local/jdk1.6.0_18/lib:/usr/local/jdk1.6.0_18/lib/tool.jar:/usr/local/jdk1.6.0_18/lib/dt.jar
CLASSPATH=$CLASSPATH:$JAVA_HOME/jre/lib
export JAVA_HOME PATH CLASSPATH
#source /etc/profile
3、Tomcat:
Tomcat默认不要配置什么东西,有就根据项目工程进行配置
启动tomcat:
#sh /usr/local/tomcat-6.0.20/bin/startup.sh
4、Urlrewrite-tomcat:
配置自己的tomcat的rewrite规则,例如
#vi /usr/local/tomcat-6.0.20/webapps/ROOT/WEB-INF/urlrewrite.xml
CODE:
重启tomcat使rewrite生效
# sh /usr/local/tomcat-6.0.20/bin/shutdown.sh
# sh /usr/local/tomcat-6.0.20/bin/startup.sh
在你对应的jsp页面加入如下信息,让伪静态页面被squid缓存:
CODE:
<%
//本页面允许在浏览器端或缓存服务器中缓存,时限为0.5小时。
Date date = new Date();
response.setDateHeader("Last-Modified",date.getTime());
response.setDateHeader("Expires",date.getTime()+(long)(0.5*3600*1000));
%>