<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest topics for the forum "Web/Application Server"]]></title>
		<link>https://forum.andowson.com/forums/show/20.page</link>
		<description><![CDATA[The newest discussed topics in the forum "Web/Application Server"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Tomcat Connector更新至1.2.40後之設定修正</title>
				<description><![CDATA[ 今天將Tomcat Connector利用自動更新程式tomcat-connector.sh(如下)進行更新: 
<br>
[code=bash] 
<br>
#!/bin/bash 
<br>
# Name: Apache 2.2.x &amp;&amp; Tomcat 7.0.x auto installer for CentOS 6.x 
<br>
# Author: Andowson Chang (andowson [at] gmail [dot] com) 
<br>
# Version: 5.16 
<br>
# Last Modified: 2014-04-20 
<br>
# Source: http://www.andowson.com 
<br>
# 
<br>
TOMCAT_CONNECTOR_VERSION=1.2.40 
<br>
<br>
MIRROR_HOST=apache.stu.edu.tw 
<br>
SETUP_DIR=/root/setup/web 
<br>
INTERNET_CONNECTED=1 
<br>
<br>
# 
<br>
# install dependency packages 
<br>
# 
<br>
LIBTOOL_INSTALLED=`rpm -qa|grep libtool|wc -l` 
<br>
HTTPD_DEVEL_INSTALLED=`rpm -qa|grep httpd-devel|wc -l` 
<br>
AUTOMAKE_INSTALLED=`rpm -qa|grep automake|wc -l` 
<br>
if [ ${LIBTOOL_INSTALLED} = 0 ] || [ ${HTTPD_DEVEL_INSTALLED} = 0 ] || [ ${AUTOMAKE_INSTALLED} = 0 ]; then 
<br>
 yum -y install libtool httpd-devel automake 
<br>
fi 
<br>
<br>
# 
<br>
# create the setup directory 
<br>
# 
<br>
if [ ! -d ${SETUP_DIR} ]; then 
<br>
 mkdir -p ${SETUP_DIR} 
<br>
fi 
<br>
cd ${SETUP_DIR} 
<br>
<br>
# 
<br>
# get latest version 
<br>
# 
<br>
wget http://tomcat.apache.org/download-connectors.cgi -q -t 1 -T 5 -O /tmp/connector.html 
<br>
if [ -s /tmp/connector.html ]; then 
<br>
 TOMCAT_CONNECTOR_VERSION=`grep "1\.2\." /tmp/connector.html|cut -d"&gt;" -f2|cut -d"&lt;" -f1 |awk '{print $2}'|grep "1.2"|uniq` 
<br>
else 
<br>
 echo "Cannot connect to the Internet. Try using local file instead." 
<br>
 INTERNET_CONNECTED=0 
<br>
fi 
<br>
rm -rf /tmp/connector.html 
<br>
if [ ! -r tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz ]; then 
<br>
 if [ $INTERNET_CONNECTED -eq 1 ]; then 
<br>
 wget http://${MIRROR_HOST}/tomcat/tomcat-connectors/jk/tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz 
<br>
 else 
<br>
 echo "File not found: tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz, aborted!" 
<br>
 exit 1 
<br>
 fi 
<br>
fi 
<br>
<br>
# 
<br>
# install tomcat connector 
<br>
# 
<br>
echo "Install Tomcat Connector JK ${TOMCAT_CONNECTOR_VERSION}" 
<br>
tar zxvf tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz 
<br>
cd tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src/native 
<br>
./buildconf.sh 
<br>
./configure --with-apxs=/usr/sbin/apxs 
<br>
make 
<br>
make install 
<br>
cd ${SETUP_DIR} 
<br>
[/code] 
<br>
<br>
完成更新後，重啟Apache，再去開網頁卻無法順利開啟網頁，查了一下mod_jk.log: 
<br>
[code=plain][Sun Apr 20 13:30:34 2014][15480:139841517975520] [info] init_jk::mod_jk.c (3383): mod_jk/1.2.40 initialized 
<br>
[Sun Apr 20 13:30:34 2014][15482:139841517975520] [info] init_jk::mod_jk.c (3383): mod_jk/1.2.40 initialized 
<br>
[Sun Apr 20 13:30:39 2014][15492:139841517975520] [info] jk_open_socket::jk_connect.c (758): connect to ::1:8109 failed (errno=111) 
<br>
[Sun Apr 20 13:30:39 2014][15492:139841517975520] [info] ajp_connect_to_endpoint::jk_ajp_common.c (1019): Failed opening socket to (::1:8109) (errno=111) 
<br>
[Sun Apr 20 13:30:39 2014][15492:139841517975520] [error] ajp_send_request::jk_ajp_common.c (1663): (worker1) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=111) 
<br>
[Sun Apr 20 13:30:39 2014][15492:139841517975520] [info] ajp_service::jk_ajp_common.c (2673): (worker1) sending request to tomcat failed (recoverable), because of error during request sending (attempt=1)[/code] 
<br>
<br>
發現無法連到::1:8109(這是IPv6的locahost IP表示方法) 
<br>
在查了一下Tomcat的[url=http://tomcat.apache.org/connectors-doc/miscellaneous/changelog.html]Changelog網頁[/url] 
<br>
[quote]Add IPV6 support for connection to webserver. New directive prefer_ipv6 has been added to control the hostname resolution and preserve backward compatibility. (mturk)[/quote] 
<br>
感覺應該是預設用IPv6在抓IP，由於我不知道怎麼調整這個預設模式，故我採用修改workers.properties 
<br>
將這兩行設定的localhost 
<br>
[code]worker.worker1.host=localhost 
<br>
worker.worker2.host=localhost[/code] 
<br>
改為127.0.0.1 
<br>
[code]worker.worker1.host=127.0.0.1 
<br>
worker.worker2.host=127.0.0.1[/code] 
<br>
再重啟一次Apache，就可以順利連到Tomcat了。]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/623/1307.page</guid>
				<link>https://forum.andowson.com/posts/preList/623/1307.page</link>
				<pubDate><![CDATA[Sun, 20 Apr 2014 15:29:47]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
			<item>
				<title>[Tomcat]Deploy war檔時，讓每個context都有各自的AccessLogValve</title>
				<description><![CDATA[ 當您想要使用tomcat的AccessLogValve讓每個context都有各自的accesslog時， 
<br>
方法很簡單，在您的war專案內，新增一個 /META-INF/context.xml 檔，編輯內容如下 : 
<br>
[code] 
<br>
<br>
 ...... 
<br>
<br>
<br>
 prefix="MyWeb_access_log." suffix=".log" pattern="common" resolveHosts="false"/&gt; 
<br>
<br>
<br>
[/code] 
<br>
當您將war檔deploy之後，Tomcat會自動幫您產生一個檔案 : {tomcat_home}/conf/Catalina/localhost/MyWeb.xml 
<br>
然後在您的{tomcat_home}/logs/ 目錄下應該就可以看到您的MyWeb_access_log.xxxx.txt 檔了。]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/610/1289.page</guid>
				<link>https://forum.andowson.com/posts/preList/610/1289.page</link>
				<pubDate><![CDATA[Mon, 13 May 2013 11:21:32]]> GMT</pubDate>
				<author><![CDATA[ jhliang]]></author>
			</item>
			<item>
				<title>回覆:Linux環境下Tomcat catalina.out的管理</title>
				<description><![CDATA[ 第二天: 
<br>
如果順利切換過去，接下來就是將先前/etc/logrotate.d/tomcat中mark掉的mail developer等設定恢復。 
<br>
<br>
再來可能會遇到的問題就是，昨天logrotate後，那個20幾GB的catalina.out現在只是檔名尾巴加上日期，大小還是20幾GB大。如果我們希望也能夠將它切一切，也一樣照日期分成一個一個檔，那應該如何處理呢? 
<br>
<br>
由於沒有現成的工具程式(或是我不知道有這種工具)可以處理catalina.out-20120801，於是我先土法煉鋼來處理這個切檔的工作: 
<br>
先用vi開啟這個檔案(是的，20幾GB)，然後找到昨天的日期第一次出現在這個檔案的行數，再找出檔案尾巴的行數，將這個區塊寫到另一個檔案去，例如catalina.out-20120731，再將原先的catalina.out-20120801檔案刪掉該區塊的內容。這樣子重複執行直到將檔案全部切好為止。 
<br>
<br>
我手動切了三個日期後，就覺得這樣子下去不是辦法，應該可以寫個shell script來處理這件事: 
<br>
1.使用grep -n指令搭配head -1來找出某個日期第一次出現在檔案中的行號: 
<br>
grep -n "2012/7/31" catalina.out-20120801|head -1|awk '{print $1}'|cut -d":" -f1 
<br>
2.然後利用wc -l 來找出檔案尾巴行數: 
<br>
wc -l catalina.out-20120801|awk '{print $1}' 
<br>
3.接下來利用expr將兩個行號相減再加一: 
<br>
expr $end - $start + 1 
<br>
4.再利用tail 指令搭配行數，將自檔尾倒數幾行寫到檔案catalina.out-20120731去 
<br>
tail -$lines catalina.out-20120801 &gt; catalina.out-20120731 
<br>
5.最後再利用sed指令去刪掉剛剛自起始行號到結尾行號中間的檔案內容 
<br>
sed -i -e "${start},${end}d" catalina.out-20120801 
<br>
<br>
搭配一下日期年月日的迴圈後可以組成如下: 
<br>
split_catalina_out.sh: 
<br>
[code]#!/bin/bash 
<br>
file=catalina.out-20120801 
<br>
for y in {2012..2011} 
<br>
do 
<br>
 for m in {12..1} 
<br>
 do 
<br>
 for d in {31..1} 
<br>
 do 
<br>
 target="$y/$m/$d" 
<br>
 target_ym="${y}${m}" 
<br>
 if [ $m -lt 10 ]; then 
<br>
 target_ym="${y}0${m}" 
<br>
 fi 
<br>
 target_date="${target_ym}${d}" 
<br>
 if [ $d -lt 10 ]; then 
<br>
 target_date="${target_ym}0${d}" 
<br>
 fi 
<br>
<br>
 start=`grep -n $target $file|head -1|awk '{print $1}'|cut -d":" -f1` 
<br>
 if [ "$start" == "" ]; then 
<br>
 continue 
<br>
 fi 
<br>
 end=`wc -l $file|awk '{print $1}'` 
<br>
 lines=`expr $end - $start + 1` 
<br>
 echo $target_date 
<br>
 tail -$lines $file &gt; ./catalina.out-$target_date 
<br>
 sed -i -e "${start},${end}d" $file 
<br>
 done 
<br>
 done 
<br>
done[/code] 
<br>
<br>
建議先複製一份catalina.out-20120801到/tmp目錄，測試看看，以免毀了原始紀錄檔。將split_catalina_out.sh放在和catalina.out-20120801相同的目錄下，執行時程式會自動判斷該日期是否存在於檔案中，如不存在將自動跳過。如此不斷重複直到回圈執行完畢。]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/586/1239.page</guid>
				<link>https://forum.andowson.com/posts/preList/586/1239.page</link>
				<pubDate><![CDATA[Thu, 2 Aug 2012 00:26:14]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
			<item>
				<title>回覆:如何限制只有某些IP才能使用Tomcat Manager</title>
				<description><![CDATA[ Tomcat 7.0的設定方法: 
<br>
將webapps/host-manager/manager.xml 複製到conf/Catalina/localhost下 
<br>
<br>
在manager.xml中加入下列設定到Context 
<br>
[code]&lt;Valve className="org.apache.catalina.valves.RemoteAddrValve" 
<br>
 allow="127\.0\.0\.1|114\.\d+\.\d+\.\d+" denyStatus="404" /&gt;[/code] 
<br>
兩個以上的IP用"|"分隔，注意到.前面要加上倒斜線(\)。 
<br>
如: 
<br>
[code]&lt;Context docBase="${catalina.home}/webapps/manager" 
<br>
 privileged="true" antiResourceLocking="false" antiJARLocking="false"&gt; 
<br>
 &lt;Valve className="org.apache.catalina.valves.RemoteAddrValve" 
<br>
 allow="127\.0\.0\.1|114\.\d+\.\d+\.\d+" denyStatus="404" /&gt; 
<br>
&lt;/Context&gt;[/code] 
<br>
<br>
實際測試，發現不需重啟Tomcat立即生效 
<br>
<br>
參考資料: 
<br>
http://tomcat.apache.org/tomcat-7.0-doc/config/valve.html#Remote_Address_Filter]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/84/1231.page</guid>
				<link>https://forum.andowson.com/posts/preList/84/1231.page</link>
				<pubDate><![CDATA[Sun, 8 Jul 2012 11:04:53]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
			<item>
				<title>回覆:Apache Rewrite 問題</title>
				<description><![CDATA[ 試試看這樣子行不行? 
<br>
[code]RewriteRule ^/mini-itx.jsp$ /abc.jsp?id=1&amp;name=mini-itx [P][/code]]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/583/1230.page</guid>
				<link>https://forum.andowson.com/posts/preList/583/1230.page</link>
				<pubDate><![CDATA[Sun, 17 Jun 2012 11:26:52]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
			<item>
				<title>回覆:讓Tomcat啟動時支援JMX，可以透過JConsole遠端管理</title>
				<description><![CDATA[ 謝謝 andowson 
<br>
我是初學者，這文章對我來說非常有用 
<br>
感謝]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/424/1174.page</guid>
				<link>https://forum.andowson.com/posts/preList/424/1174.page</link>
				<pubDate><![CDATA[Thu, 10 Nov 2011 16:48:28]]> GMT</pubDate>
				<author><![CDATA[ goodrockey]]></author>
			</item>
			<item>
				<title>在 CentOS 5 上安裝 WebLogic Server 10.0 MP1</title>
				<description><![CDATA[ 在 CentOS 5 上安裝 WebLogic Server 10.0 MP1 
<br>
<br>
設計理念: 
<br>
1.需要啟動兩個WebLogic Server，一個是AdminServer，一個是ManagedServer。AdminServer負責管理Project Domain，ManagedServer負責執行被佈署上去的WebApp。 
<br>
2.因為該主機上尚需執行其他AP Server(如Tomcat)，我們讓ManagedServer跑在Port 8081上，並透過proxy機制整合至Apache以免佔用port 80。 
<br>
<br>
實作步驟: 
<br>
1.安裝JDK 5.0 
<br>
 :!: WebLogic Server 10.0 MP1必須搭配JDK 5.0版本使用，如果改用JDK 6.0，雖然可以執行，但將會在log檔中看到一堆錯誤訊息，且運作起來會有很多不順的現象。如果系統上已經安裝JDK 6.0者須先反安裝，待安裝完JDK 5.0後再裝回JDK 6.0。 
<br>
 :arrow: 下載Sun Java Development Kit 5.0 Update 22(JDK 5.0在2009/11/3被宣告EOSL，最後的公眾可下載版本是Update 22，如果有購買Java SE for Business者可下載較新版本) 
<br>
x86_64: 
<br>
[code=bash]cd /tmp 
<br>
wget http://download.oracle.com/otn-pub/java/jdk/1.5.0_22/jdk-1_5_0_22-linux-amd64-rpm.bin -O jdk-1_5_0_22-linux-amd64-rpm.bin[/code] 
<br>
x86: 
<br>
[code=bash]cd /tmp 
<br>
wget http://download.oracle.com/otn-pub/java/jdk/1.5.0_22/jdk-1_5_0_22-linux-i586-rpm.bin -O jdk-1_5_0_22-linux-i586-rpm.bin[/code] 
<br>
 :arrow: 安裝JDK 5.0 Update 22 
<br>
[code=bash]sh jdk-1_5_0_22-linux-amd64-rpm.bin[/code] 
<br>
 :idea: 安裝路徑:/usr/java/jdk1.5.0_22 
<br>
<br>
2.安裝WebLogic Server 
<br>
 :arrow: 上傳光碟檔案B46881-01.zip至/tmp目錄下 
<br>
 :arrow: 解壓縮 
<br>
[code=bash]cd /tmp 
<br>
unzip B46881-01.zip 
<br>
[/code] 
<br>
 :arrow: 開始安裝 
<br>
[code=bash]java -jar server1001_generic.jar[/code] 
<br>
<br>
BEA_HOME=/var/bea 
<br>
選擇自訂安裝，取消安裝Server Examples [1.2]及Workshop for WebLogic Platform [2] 
<br>
<br>
3.建立WebLogic Domain 
<br>
[code=bash]cd /var/bea/wlserver_10.0/common/bin 
<br>
./config.sh 
<br>
[/code] 
<br>
設定weblogic的密碼 
<br>
設定啟動模式: Development Mode 
<br>
選擇JDK的路徑:/usr/java/jdk1.5.0_22 
<br>
<br>
<br>
4.上傳啟動用的shell script至/var/bea/user_projects/domains/base_domain/ 
<br>
 :arrow: 先將原本產生的startWebLogic.sh更名 
<br>
[code=bash]cd /var/bea/user_projects/domains/base_domain/ 
<br>
mv startWebLogic.sh startWebLogic.sh.orig 
<br>
chmod a-x startWebLogic.sh.orig 
<br>
[/code] 
<br>
 :arrow: 上傳下列檔案 
<br>
startAdminServer.sh 
<br>
startManagedServer.sh 
<br>
startOnBoot.sh 
<br>
startWebLogic.sh 
<br>
stopAdminServer.sh 
<br>
stopManagedServer.sh 
<br>
 :arrow: 編輯下列檔案，取代AdminServer的IP 
<br>
startManagedServer.sh 
<br>
stopManagedServer.sh 
<br>
 :arrow: 將檔案設定為可執行 
<br>
[code=bash] 
<br>
cd /var/bea/user_projects/domains/base_domain/ 
<br>
chmod a+x *.sh 
<br>
[/code] 
<br>
<br>
<br>
5.建立boot.properties符號連結 
<br>
[code=bash]cd /var/bea/user_projects/domains/base_domain/ 
<br>
ln -s servers/AdminServer/security/boot.properties boot.properties 
<br>
[/code] 
<br>
<br>
6.建立Log目錄 
<br>
[code=bash]mkdir -p /var/log/bea[/code] 
<br>
<br>
7.啟動AdminServer 
<br>
[code=bash]cd /var/bea/user_projects/domains/base_domain/ 
<br>
./startAdminServer.sh[/code] 
<br>
<br>
8.開放防火牆iptables 
<br>
加上下列port 
<br>
7001:tcp 
<br>
<br>
9.登入weblogic console 
<br>
 :arrow: 開啟瀏覽器，輸入下列網址 
<br>
http://my_server_ip:7001/console/ 
<br>
帳號跟密碼就是步驟3.建立WebLogic Domain時所輸入的資訊 
<br>
 :arrow: 建立一個新的Server: 
<br>
Name: ManagedServer 
<br>
Listen Port: 8081 
<br>
<br>
10.啟動ManagedServer 
<br>
[code=bash]cd /var/bea/user_projects/domains/base_domain/ 
<br>
./startManagedServer.sh[/code] 
<br>
<br>
11.檢查ManagedServer的狀態是否為RUNNING 
<br>
<br>
12.關閉ManagedServer: 
<br>
[code=bash]cd /var/bea/user_projects/domains/base_domain/ 
<br>
./stopManagedServer.sh[/code] 
<br>
<br>
13.關閉AdminServer: 
<br>
[code=bash]cd /var/bea/user_projects/domains/base_domain/ 
<br>
./stopAdminServer.sh[/code] 
<br>
<br>
到此完成WebLogic Server 10.0 MP1的安裝 
<br>
<br>
接下來再透過WebLogic Server的Apache HTTP Server Plug-In整合至Apache HTTP Server 2.2 
<br>
x86_64: 
<br>
[code=bash]cp -p /var/bea/wlserver_10.0/server/plugin/linux/x86_64/mod_wl_22.so /etc/httpd/modules/.[/code] 
<br>
x86: 
<br>
[code=bash]cp -p /var/bea/wlserver_10.0/server/plugin/linux/i686/mod_wl_22.so /etc/httpd/modules/.[/code] 
<br>
vi /etc/httpd/conf.d/mod_wl.conf 
<br>
[code=text]LoadModule weblogic_module modules/mod_wl_22.so 
<br>
&lt;IfModule mod_weblogic.c&gt; 
<br>
 WebLogicHost localhost 
<br>
 WebLogicPort 8081 
<br>
 MatchExpression *.jsp 
<br>
&lt;/IfModule&gt; 
<br>
<br>
&lt;Location /myapp&gt; 
<br>
 SetHandler weblogic-handler 
<br>
&lt;/Location&gt;[/code] 
<br>
<br>
 :arrow: 測試一下設定有沒有問題: 
<br>
[code=bash]httpd -t[/code] 
<br>
如果出現Syntax OK就表示沒問題了 
<br>
<br>
 :arrow: 重新啟動WebLogic Server和Apache Server 
<br>
[code=bash]cd /var/bea/user_projects/domains/base_domain/ 
<br>
./startOnBoot.sh 
<br>
/etc/init.d/httpd restart[/code] 
<br>
就可以透過下面的網址來存取myapp了 
<br>
http://my_server_ip/myapp 
<br>
<br>
參考資料: 
<br>
http://download.oracle.com/docs/cd/E13222_01/wls/docs100/plugins/apache.html]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/564/1167.page</guid>
				<link>https://forum.andowson.com/posts/preList/564/1167.page</link>
				<pubDate><![CDATA[Wed, 2 Nov 2011 11:21:21]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
			<item>
				<title>Apache 2.2 + SSL + JK 1.2 + Tomcat 7.0 Clustering Auto Installer for CentOS 6.0</title>
				<description><![CDATA[ An Auto Installer for Integrating Apache 2.2 and Tomcat 7.0 for Clustering/Session Replication, Load Balancing with mod_jk 1.2 on CentOS 6.0 
<br>
Author: Andowson Chang 
<br>
Date: 2011.09.29 
<br>
<br>
Design: 
<br>
1. One Apache and Two Tomcat workers on the same machine. 
<br>
2. Use mod_jk for load balancer 
<br>
3. Use mod_ssl for SSL 
<br>
4. Enable cluster configuration on both Tomcat workers to do session replication 
<br>
[img]http://andowson.myweb.hinet.net/img/apache_tomcat_integration.jpg[/img] 
<br>
<br>
Steps: 
<br>
1.Install CentOS 6.0 ([color=red]disbale SELinux and Firewall[/color]) 
<br>
2.Install JRE 
<br>
3.Install Apache and mod_ssl 
<br>
4.Generate SSL key and certificate 
<br>
5.Edit httpd.conf 
<br>
6.Edit ssl.conf 
<br>
7.Install Tomcat, mod_jk 
<br>
8.Edit server.xml 
<br>
9.Edit mod_jk.conf 
<br>
10.Edit workers.properties 
<br>
11.Edit uriworkermap.properties 
<br>
12.Start Apache and Tomcat 
<br>
<br>
Testing: 
<br>
1.Browsing http://&lt;your_server_ip&gt;/clustertest.jsp, add some keys and values. 
<br>
2.Shutdown worker1 
<br>
3.Browsing http://&lt;your_server_ip&gt;/clustertest.jsp, check if the keys and values are still there. 
<br>
4.Run restart.sh 
<br>
5.Browsing http://&lt;your_server_ip&gt;/clustertest.jsp, check if the keys and values are still there. 
<br>
6.Browsing https://&lt;your_server_ip&gt;/clustertest.jsp, check if the keys and values are still there. 
<br>
<br>
Implementation: 
<br>
1.Choose Minimal when install CentOS 6.0 
<br>
2.Create a directory /root/setup and download the auto installer script for step 2-11, save it as httpd2_tomcat7_setup.sh in /root/setup 
<br>
[code=text] 
<br>
mkdir -p /root/setup 
<br>
wget http://www.andowson.com/download/httpd2_tomcat7_setup.sh 
<br>
[/code] 
<br>
then run it 
<br>
[code=text] 
<br>
chmod 755 /root/setup/httpd2_tomcat7_setup.sh 
<br>
cd /root/setup 
<br>
./httpd2_tomcat7_setup.sh 
<br>
[/code] 
<br>
<br>
[b]httpd2_tomca7_setup.sh[/b]: 
<br>
[code=bash] 
<br>
#!/bin/bash 
<br>
# Name: Apache 2.2.x &amp;&amp; Tomcat 7.0.x auto installer for CentOS 6.x 
<br>
# Author: Andowson Chang (andowson [at] gmail [dot] com) 
<br>
# Version: 5.15 
<br>
# Last Modified: 2011-09-29 
<br>
# Source: http://www.andowson.com 
<br>
# 
<br>
# Assumption: 
<br>
# * FQDN hostname is correctly set on /etc/sysconfig/network and /etc/hosts 
<br>
# ex. 
<br>
# /etc/sysconfig/network: 
<br>
# HOSTNAME=www.andowson.com 
<br>
# /etc/hosts: 
<br>
# 192.168.1.1 www.andowson.com www 
<br>
# (reboot after modified) 
<br>
# * run this script as root user 
<br>
# Post-Install: 
<br>
# * disable SELINUX: 
<br>
# /etc/selinux/config 
<br>
# SELINUX=disabled 
<br>
# (reboot after modified) 
<br>
# * allow HTTP(80:tcp), HTTPS(443:tcp), 45564:udp in iptables 
<br>
# 
<br>
# This program will 
<br>
# 1.install JRE 7 
<br>
# 2.install httpd and mod_ssl 
<br>
# 3.modify /etc/http/conf/httpd.conf 
<br>
# 4.generate SSL key and a self-signed certificate 
<br>
# 5.modify /etc/http/conf.d/ssl.conf 
<br>
# 6.check for the lastest stable version of Tomcat 7.0.x 
<br>
# 7.download apache-tomcat-7.0.x.tar.gz 
<br>
# 8.unpack it into /var/apache-tomcat-7.0.x 
<br>
# 9.make a symbolic link /var/tomcat7 to the above directory for easy upgrade 
<br>
# to a later version 
<br>
# 10.check memory size to determine some JVM parameters 
<br>
# 11.check for the latest stable verion of Tomcat Connector 1.2.x 
<br>
# 12.download tomcat-connectors-1.2.x-src.tar.gz 
<br>
# 13.unpack it 
<br>
# 14.configure, make and make install 
<br>
# 15.create user tomcat with home directory /var/tomcat7 
<br>
# 16.make two instances of tomcat for load balancing, here I put them under 
<br>
# /var/robust/worker[1,2] for easy to backup all of them. 
<br>
# 17.setup default host directory(for testing) 
<br>
# 18.generate server.xml 
<br>
# 19.generate tomcat-users.xml 
<br>
# 20.modify web.xml for production use 
<br>
# 21.generate mod_jk.conf 
<br>
# 22.generate workers.properties 
<br>
# 23.generate uriworkermap.properties 
<br>
# 24.generate tomcat startup script 
<br>
# 25.modify web.xml for cluster test 
<br>
# 26.generate clustertest.jsp for cluster test 
<br>
# 27.generate cleanup.sh for easy to uninstall everything 
<br>
<br>
# 
<br>
# intranet workaround 
<br>
# If your server doesn't have direct access to the Internet, ie. in the company 
<br>
# intranet behind a firewall, you can modify your server's proxy setting by edit 
<br>
# /etc/wgetrc: 
<br>
#http_proxy = http://proxy.yourcompany.com:8080/ 
<br>
#use_proxy = on 
<br>
<br>
# If you still can't use proxy then you have to download all the files manually. 
<br>
# After download, copy them into ${SETUP_DIR}. And then change the following 
<br>
# default version number to the correct number you have downloaded. 
<br>
# 
<br>
TOMCAT_VERSION=7.0.21 
<br>
TOMCAT_CONNECTOR_VERSION=1.2.32 
<br>
<br>
# 
<br>
# auto detect ip and hostname 
<br>
# 
<br>
ip=`/sbin/ifconfig|grep "inet addr"|awk '{print $2}'|cut -d":" -f2|head -1` 
<br>
hostname=`/bin/hostname -f` 
<br>
<br>
# 
<br>
# adjustable parameters, you can modify any of them to fit your own need 
<br>
# 
<br>
DOMAIN=`/bin/hostname -d` 
<br>
COUNTRY=TW 
<br>
STATE=Taiwan 
<br>
LOCATION=Taipei 
<br>
COMPANY="Andowson Ltd." 
<br>
ORGANIZATION= 
<br>
HOSTNAME=${hostname} 
<br>
hostname=${ip} 
<br>
MIRROR_HOST=apache.ntu.edu.tw 
<br>
CATALINA_HOME=/var/tomcat7 
<br>
WORKER_ROOT=/var/robust 
<br>
WEBAPP_ROOT=/var/webapps 
<br>
SETUP_DIR=/root/setup/web 
<br>
<br>
# 
<br>
# create the setup directory 
<br>
# 
<br>
mkdir -p ${SETUP_DIR} 
<br>
cd ${SETUP_DIR} 
<br>
echo '/etc/init.d/tomcat stop' &gt; ${SETUP_DIR}/cleanup.sh 
<br>
echo '/etc/init.d/httpd stop' &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
<br>
# 
<br>
# install JRE 
<br>
# 
<br>
OS_MODEL=`uname -m` 
<br>
JRE_FILE="" 
<br>
if [ ${OS_MODEL} == "i686" ]; then 
<br>
 JRE_FILE="jdk-7-linux-i586.rpm" 
<br>
elif [ ${OS_MODEL} == "x86_64" ]; then 
<br>
 JRE_FILE="jdk-7-linux-x64.rpm" 
<br>
fi 
<br>
echo "Install ${JRE_FILE}" 
<br>
if [ -n ${JRE_FILE} ] &amp;&amp; [ ! -r ${JRE_FILE} ]; then 
<br>
 wget http://download.oracle.com/otn-pub/java/jdk/7/${JRE_FILE} -O ${JRE_FILE} 
<br>
fi 
<br>
if [ -r ${JRE_FILE} ]; then 
<br>
 rpm -Uvh ${JRE_FILE} 
<br>
fi 
<br>
<br>
# 
<br>
# install httpd and mod_ssl 
<br>
# 
<br>
yum -y install httpd mod_ssl 
<br>
cp -p /etc/httpd/conf/httpd.conf /tmp/httpd.conf 
<br>
cp -p /etc/httpd/conf.d/ssl.conf /tmp/ssl.conf 
<br>
<br>
# 
<br>
# modify httpd.conf 
<br>
# 
<br>
sed -i -e "s/ServerTokens OS/ServerTokens ProductOnly/g" \ 
<br>
-e "s/KeepAlive Off/KeepAlive On/g" \ 
<br>
-e "s/Group apache/Group tomcat/g" \ 
<br>
-e "s/root@localhost/webmaster@${DOMAIN}/g" \ 
<br>
-e "276a\ServerName ${HOSTNAME}:80" \ 
<br>
-e "292a\VirtualDocumentRoot /var/webapps/%0" \ 
<br>
-e "s/DirectoryIndex index.html index.html.var/DirectoryIndex sorry.html index.html index.htm default.html default.htm index.html.var index.jsp/g" \ 
<br>
-e '500a\LogFormat "%V %h %l %u %t \\"%r\\" %&gt;s %b" vcommon' \ 
<br>
-e '500a\LogFormat "%V %h %l %u %t \\"%r\\" %&gt;s %b \\"%{Referer}i\\" \\"%{User-Agent}i\\"" vcombined' \ 
<br>
-e '504c\LogFormat "%h %l %u %t \\"%r\\" %&gt;s %b \\"%{Referer}i\\" \\"%{User-Agent}i\\" %I %O" combinedio' \ 
<br>
-e "526c\CustomLog logs/access_log combinedio\nCustomLog logs/vhost.log vcombined" \ 
<br>
-e "s/ServerSignature On/ServerSignature Off/g" \ 
<br>
-e "743c\LanguagePriority zh-TW en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN" \ 
<br>
-e "972a\&lt;Location /&gt;" \ 
<br>
-e "972a\ # Insert filter" \ 
<br>
-e "972a\ SetOutputFilter DEFLATE\n" \ 
<br>
-e "972a\ # Netscape 4.x has some problems..." \ 
<br>
-e "972a\ BrowserMatch ^Mozilla/4 gzip-only-text/html\n" \ 
<br>
-e "972a\ # Netscape 4.06-4.08 have some more problems" \ 
<br>
-e '972a\ BrowserMatch ^Mozilla/4\\.0[678] no-gzip\n' \ 
<br>
-e "972a\ # MSIE masquerades as Netscape, but it is fine" \ 
<br>
-e '972a\ # BrowserMatch \\bMSIE \!no-gzip \!gzip-only-text/html\n' \ 
<br>
-e "972a\ # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48" \ 
<br>
-e "972a\ # the above regex won't work. You can use the following" \ 
<br>
-e "972a\ # workaround to get the desired effect:" \ 
<br>
-e '972a\ BrowserMatch \\bMSI[E] \!no-gzip \!gzip-only-text/html\n' \ 
<br>
-e "972a\ # Don't compress images" \ 
<br>
-e '972a\ SetEnvIfNoCase Request_URI \\.(?:gif|jpe?g|png)$ no-gzip dont-vary\n' \ 
<br>
-e "972a\ # Make sure proxies don't deliver the wrong content" \ 
<br>
-e "972a\ Header append Vary User-Agent env=\!dont-vary" \ 
<br>
-e "972a\&lt;/Location&gt;\n" \ 
<br>
-e "972a\RewriteEngine on" \ 
<br>
-e "972a\RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)" \ 
<br>
-e "972a\RewriteRule .* - [F]\n" /etc/httpd/conf/httpd.conf 
<br>
echo 'cp -p /tmp/httpd.conf /etc/httpd/conf/httpd.conf' &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
<br>
# 
<br>
# generate SSL key and cert 
<br>
# 
<br>
openssl genrsa -out /etc/pki/tls/private/${HOSTNAME}.key 2048 
<br>
openssl req -new -key /etc/pki/tls/private/${HOSTNAME}.key -out /etc/pki/tls/certs/${HOSTNAME}.csr -subj "/C=${COUNTRY}/ST=${STATE}/L=${LOCATION}/O=${COMPANY}/OU=${ORGANIZATION}/CN=${HOSTNAME}" 
<br>
openssl x509 -req -days 3650 -in /etc/pki/tls/certs/${HOSTNAME}.csr -signkey /etc/pki/tls/private/${HOSTNAME}.key -out /etc/pki/tls/certs/${HOSTNAME}.crt 
<br>
echo 'rm -rf /etc/pki/tls/private/'${HOSTNAME}'.key' &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
echo 'rm -rf /etc/pki/tls/certs/'${HOSTNAME}'.csr' &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
echo 'rm -rf /etc/pki/tls/certs/'${HOSTNAME}'.crt' &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
<br>
# 
<br>
# modify ssl.conf 
<br>
# 
<br>
sed -i -e "79a\JkMountFile conf/uriworkermap.properties\n" \ 
<br>
-e "s/localhost.crt/${HOSTNAME}.crt/g" \ 
<br>
-e "s/localhost.key/${HOSTNAME}.key/g" /etc/httpd/conf.d/ssl.conf 
<br>
echo 'cp -p /tmp/ssl.conf /etc/httpd/conf.d/ssl.conf' &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
<br>
/sbin/chkconfig --level 235 httpd on 
<br>
echo '/sbin/chkconfig httpd off' &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
<br>
# 
<br>
# check the latest stable version of Tomcat 7.0.x 
<br>
# 
<br>
wget http://tomcat.apache.org/whichversion.html -q -t 1 -T 5 -O /tmp/tomcat.html 
<br>
if [ -s /tmp/tomcat.html ]; then 
<br>
 TOMCAT_VERSION=`grep "7\.0\." /tmp/tomcat.html|grep -v "7\.0\.x"|cut -d"&gt;" -f2|cut -d"&lt;" -f1` 
<br>
fi 
<br>
rm -rf /tmp/tomcat.html 
<br>
<br>
echo "Install Tomcat ${TOMCAT_VERSION}" 
<br>
if [ ! -r apache-tomcat-${TOMCAT_VERSION}.tar.gz ]; then 
<br>
 wget http://${MIRROR_HOST}/tomcat/tomcat-7/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz 
<br>
fi 
<br>
tar zxvf apache-tomcat-${TOMCAT_VERSION}.tar.gz -C /var 
<br>
ln -s /var/apache-tomcat-${TOMCAT_VERSION} ${CATALINA_HOME} 
<br>
<br>
echo 'rm -rf /var/apache-tomcat-'${TOMCAT_VERSION} &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
echo 'rm -rf '${CATALINA_HOME} &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
<br>
# 
<br>
# check memory size to determine some JVM parameters 
<br>
# 
<br>
mem=`cat /proc/meminfo|grep "MemTotal:"|awk '{print $2}'` 
<br>
let KB=1024 
<br>
let memsize=$mem/$KB 
<br>
let heapsize=$memsize/2 
<br>
let newsize=$heapsize/4 
<br>
echo 'JAVA_HOME="/usr/java/latest" 
<br>
JAVA_OPTS="-server -XX:NewSize='${newsize}'m -XX:MaxNewSize='${newsize}'m -XX:SurvivorRatio=8 -XX:MaxPermSize=128m -Xss256k -Xms'${heapsize}'m -Xmx'${heapsize}'m -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true"' &gt; ${CATALINA_HOME}/bin/setenv.sh 
<br>
chmod 755 ${CATALINA_HOME}/bin/setenv.sh 
<br>
<br>
# 
<br>
# check the latest stable version of Tomcat Connector 1.2.x 
<br>
# 
<br>
# pre-requirment 
<br>
yum -y install httpd-devel apr-devel libtool automake make gcc gcc-c++ 
<br>
<br>
wget http://tomcat.apache.org/download-connectors.cgi -q -t 1 -T 5 -O /tmp/connector.html 
<br>
if [ -s /tmp/connector.html ]; then 
<br>
 TOMCAT_CONNECTOR_VERSION=`grep "1\.2\." /tmp/connector.html|cut -d"&gt;" -f2|cut -d"&lt;" -f1 |awk '{print $2}'|grep "1.2"|uniq` 
<br>
fi 
<br>
rm -rf /tmp/connector.html 
<br>
echo "Install Tomcat Connector JK ${TOMCAT_CONNECTOR_VERSION}" 
<br>
if [ ! -r tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz ]; then 
<br>
 wget http://${MIRROR_HOST}/tomcat/tomcat-connectors/jk/tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz 
<br>
fi 
<br>
tar zxvf tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz 
<br>
cd tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src/native 
<br>
./buildconf.sh 
<br>
./configure --with-apxs=/usr/sbin/apxs 
<br>
make 
<br>
make install 
<br>
cd ${SETUP_DIR} 
<br>
echo 'rm -rf /etc/httpd/modules/mod_jk.so' &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
<br>
# 
<br>
# add user tomcat 
<br>
# 
<br>
/usr/sbin/groupadd -g 80 tomcat 
<br>
/usr/sbin/useradd tomcat -u 80 -g tomcat -d ${CATALINA_HOME} -M 
<br>
echo '/usr/sbin/userdel -r tomcat' &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
<br>
# 
<br>
# setup workers' directory 
<br>
# 
<br>
mkdir -p ${WORKER_ROOT}/worker1/logs 
<br>
mkdir -p ${WORKER_ROOT}/worker1/temp 
<br>
mkdir -p ${WORKER_ROOT}/worker1/work 
<br>
cp -rf ${CATALINA_HOME}/conf ${WORKER_ROOT}/worker1/conf 
<br>
mkdir -p ${WEBAPP_ROOT} 
<br>
ln -s ${WEBAPP_ROOT} ${WORKER_ROOT}/worker1/webapps 
<br>
cp -rf ${WORKER_ROOT}/worker1 ${WORKER_ROOT}/worker2 
<br>
echo 'rm -rf '${WORKER_ROOT} &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
echo 'rm -rf '${WEBAPP_ROOT} &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
<br>
# 
<br>
# setup default host directory 
<br>
# 
<br>
mkdir -p ${WEBAPP_ROOT}/${hostname} 
<br>
cp -rf ${CATALINA_HOME}/webapps/ROOT/* ${WEBAPP_ROOT}/${hostname}/. 
<br>
mkdir -p ${WORKER_ROOT}/worker1/conf/Catalina/${hostname} 
<br>
mkdir -p ${WORKER_ROOT}/worker2/conf/Catalina/${hostname} 
<br>
cp -rf ${CATALINA_HOME}/webapps/host-manager/manager.xml ${WORKER_ROOT}/worker1/conf/Catalina/${hostname} 
<br>
cp -rf ${CATALINA_HOME}/webapps/host-manager/manager.xml ${WORKER_ROOT}/worker2/conf/Catalina/${hostname} 
<br>
<br>
# 
<br>
# generate server.xml 
<br>
# 
<br>
echo '&lt;?xml version="1.0" encoding="utf-8"?&gt; 
<br>
&lt;Server port="workerPort" shutdown="shutdownCode"&gt; 
<br>
<br>
 &lt;!-- Prevent memory leaks due to use of particular java/javax APIs--&gt; 
<br>
 &lt;Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /&gt; 
<br>
 &lt;Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /&gt; 
<br>
 &lt;Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /&gt; 
<br>
<br>
 &lt;GlobalNamingResources&gt; 
<br>
 &lt;!-- Used by Manager webapp --&gt; 
<br>
 &lt;Resource name="UserDatabase" auth="Container" 
<br>
 type="org.apache.catalina.UserDatabase" 
<br>
 description="User database that can be updated and saved" 
<br>
 factory="org.apache.catalina.users.MemoryUserDatabaseFactory" 
<br>
 pathname="conf/tomcat-users.xml" /&gt; 
<br>
 &lt;/GlobalNamingResources&gt; 
<br>
<br>
 &lt;Service name="Catalina"&gt; 
<br>
 &lt;!-- Define an AJP 1.3 Connector on port ajpPort --&gt; 
<br>
 &lt;Connector port="ajpPort" address="127.0.0.1" 
<br>
 enableLookups="false" maxThreads="1000" connectionTimeout="3000" 
<br>
 protocol="AJP/1.3" /&gt; 
<br>
<br>
 &lt;Engine name="Catalina" defaultHost="mydomain" jvmRoute="workerNo"&gt; 
<br>
<br>
 &lt;Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/&gt; 
<br>
<br>
 &lt;!-- Use the LockOutRealm to prevent attempts to guess user passwords 
<br>
 via a brute-force attack --&gt; 
<br>
 &lt;Realm className="org.apache.catalina.realm.LockOutRealm"&gt; 
<br>
 &lt;!-- This Realm uses the UserDatabase configured in the global JNDI 
<br>
 resources under the key "UserDatabase". Any edits 
<br>
 that are performed against this UserDatabase are immediately 
<br>
 available for use by the Realm. --&gt; 
<br>
 &lt;Realm className="org.apache.catalina.realm.UserDatabaseRealm" 
<br>
 resourceName="UserDatabase"/&gt; 
<br>
 &lt;/Realm&gt; 
<br>
' &gt; /tmp/server.header.template 
<br>
<br>
sed -e "s/workerPort/8105/g" -e "s/shutdownCode/`head -1024c /dev/urandom | md5sum | cut -d " " -f1`/g" -e "s/ajpPort/8109/g" -e "s/workerNo/worker1/g" -e "s/mydomain/${hostname}/g" /tmp/server.header.template &gt; ${WORKER_ROOT}/worker1/conf/server.header 
<br>
sed -e "s/workerPort/8205/g" -e "s/shutdownCode/`head -1024c /dev/urandom | md5sum | cut -d " " -f1`/g" -e "s/ajpPort/8209/g" -e "s/workerNo/worker2/g" -e "s/mydomain/${hostname}/g" /tmp/server.header.template &gt; ${WORKER_ROOT}/worker2/conf/server.header 
<br>
rm -rf /tmp/server.header.template 
<br>
<br>
echo ' &lt;Host name="'${hostname}'" appBase="webapps/'${hostname}'" 
<br>
 unpackWARs="true" autoDeploy="true"&gt; 
<br>
 &lt;Valve className="org.apache.catalina.valves.AccessLogValve" 
<br>
 directory="logs" prefix="'${hostname}'_access_log." suffix=".txt" 
<br>
 pattern="combined" resolveHosts="false"/&gt; 
<br>
 &lt;Context path="" docBase="" reloadable="false" /&gt; 
<br>
 &lt;/Host&gt;' &gt; ${WORKER_ROOT}/worker1/conf/server.host 
<br>
<br>
cp -rf ${WORKER_ROOT}/worker1/conf/server.host ${WORKER_ROOT}/worker2/conf/server.host 
<br>
<br>
echo ' &lt;/Engine&gt; 
<br>
 &lt;/Service&gt; 
<br>
&lt;/Server&gt;' &gt; ${WORKER_ROOT}/worker1/conf/server.footer 
<br>
<br>
cp -rf ${WORKER_ROOT}/worker1/conf/server.footer ${WORKER_ROOT}/worker2/conf/server.footer 
<br>
<br>
cd ${WORKER_ROOT}/worker1/conf 
<br>
cat server.header server.host server.footer &gt; server.xml 
<br>
cd ${WORKER_ROOT}/worker2/conf 
<br>
cat server.header server.host server.footer &gt; server.xml 
<br>
<br>
# 
<br>
# generate tomcat-users.xml 
<br>
# 
<br>
MANAGER_PASSWORD=`head -1024c /dev/urandom | md5sum | cut -d " " -f1 | awk '{print substr($1,1,8)}'` 
<br>
echo '&lt;?xml version="1.0" encoding="utf-8"?&gt; 
<br>
&lt;tomcat-users&gt; 
<br>
 &lt;role rolename="manager-gui"/&gt; 
<br>
 &lt;user username="manager" password="'${MANAGER_PASSWORD}'" roles="manager-gui"/&gt; 
<br>
&lt;/tomcat-users&gt;' &gt; ${WORKER_ROOT}/worker1/conf/tomcat-users.xml 
<br>
echo 
<br>
echo "Your Tomcat Manager's login is 'manager', password is '${MANAGER_PASSWORD}'" 
<br>
echo 
<br>
cp -rf ${WORKER_ROOT}/worker1/conf/tomcat-users.xml ${WORKER_ROOT}/worker2/conf/tomcat-users.xml 
<br>
<br>
# 
<br>
# modify web.xml for production use 
<br>
# 
<br>
sed -i -e "240a\ &lt;init-param&gt;\n &lt;param-name&gt;genStringAsCharArray&lt;/param-name&gt;\n &lt;param-value&gt;true&lt;/param-value&gt;\n &lt;/init-param&gt;" \ 
<br>
-e "240a\ &lt;init-param&gt;\n &lt;param-name&gt;trimSpaces&lt;/param-name&gt;\n &lt;param-value&gt;true&lt;/param-value&gt;\n &lt;/init-param&gt;" ${WORKER_ROOT}/worker1/conf/web.xml 
<br>
cp -rf ${WORKER_ROOT}/worker1/conf/web.xml ${WORKER_ROOT}/worker2/conf/web.xml 
<br>
<br>
chmod 600 ${WORKER_ROOT}/worker*/conf/server.* 
<br>
chmod 600 ${WORKER_ROOT}/worker*/conf/tomcat-users.xml 
<br>
chown -R tomcat:tomcat ${WORKER_ROOT} 
<br>
<br>
# 
<br>
# generate mod_jk.conf 
<br>
# 
<br>
echo 'LoadModule jk_module modules/mod_jk.so 
<br>
<br>
JkWorkersFile /etc/httpd/conf/workers.properties 
<br>
JkShmFile logs/jk-runtime-status 
<br>
JkLogFile "|/usr/sbin/rotatelogs /var/log/httpd/mod_jk.log 86400" 
<br>
JkLogLevel info 
<br>
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" 
<br>
JkRequestLogFormat "%w %V %T" 
<br>
LogFormat "%h %l %u %t \"%r\" %&gt;s %b %{JK_WORKER_NAME}n %{JK_LB_FIRST_NAME}n %{JK_LB_FIRST_BUSY}n %{JK_LB_LAST_NAME}n %{JK_LB_LAST_BUSY}n" mod_jk_log 
<br>
CustomLog logs/worker_access_log mod_jk_log 
<br>
<br>
# Load mount points 
<br>
JkMountFile conf/uriworkermap.properties 
<br>
<br>
# Deny direct access to WEB-INF 
<br>
&lt;LocationMatch ".*WEB-INF.*"&gt; 
<br>
 deny from all 
<br>
&lt;/LocationMatch&gt;' &gt; /etc/httpd/conf.d/mod_jk.conf 
<br>
echo 'rm -rf /etc/httpd/conf.d/mod_jk.conf' &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
<br>
# 
<br>
# generate workers.properties 
<br>
# 
<br>
echo '# workers.properties - ajp13 
<br>
# 
<br>
# List workers 
<br>
# 
<br>
worker.list=loadbalancer, jkstatus 
<br>
<br>
# 
<br>
# Define worker1 
<br>
# 
<br>
worker.worker1.type=ajp13 
<br>
worker.worker1.host=localhost 
<br>
worker.worker1.port=8109 
<br>
worker.worker1.socket_timeout=1200 
<br>
worker.worker1.connection_pool_size=1 
<br>
worker.worker1.connection_pool_timeout=1300 
<br>
worker.worker1.lbfactor=1 
<br>
# Define prefered failover node for worker1 
<br>
worker.worker1.redirect=worker2 
<br>
<br>
# 
<br>
# Define worker2 
<br>
# 
<br>
worker.worker2.type=ajp13 
<br>
worker.worker2.host=localhost 
<br>
worker.worker2.port=8209 
<br>
worker.worker2.socket_timeout=1200 
<br>
worker.worker2.connection_pool_size=1 
<br>
worker.worker2.connection_pool_timeout=1300 
<br>
worker.worker2.lbfactor=1 
<br>
# Disable worker2 for all requests except failover 
<br>
worker.worker2.activation=d 
<br>
<br>
# 
<br>
# Defining a load balancer 
<br>
# 
<br>
worker.loadbalancer.type=lb 
<br>
worker.loadbalancer.balance_workers=worker1, worker2 
<br>
<br>
# 
<br>
# Define status worker 
<br>
# 
<br>
worker.jkstatus.type=status' &gt; /etc/httpd/conf/workers.properties 
<br>
echo 'rm -rf /etc/httpd/conf/workers.properties' &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
<br>
# 
<br>
# generate uriworkermap.properties 
<br>
# 
<br>
echo '/jkmanager/*=jkstatus 
<br>
/*.jsp=loadbalancer 
<br>
/*.page=loadbalancer 
<br>
/servlet/*=loadbalancer 
<br>
/manager/*=loadbalancer' &gt; /etc/httpd/conf/uriworkermap.properties 
<br>
echo 'rm -rf /etc/httpd/conf/uriworkermap.properties' &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
<br>
# 
<br>
# generate tomcat startup script 
<br>
# 
<br>
echo '#!/bin/sh 
<br>
# 
<br>
# tomcat Startup script for Tomcat, the Apache Servlet Engine 
<br>
# 
<br>
# chkconfig: - 84 16 
<br>
# description: Tomcat Servlet Engine 
<br>
# processname: tomcat 
<br>
# pidfile: /var/run/worker1.pid /var/run/worker2.pid 
<br>
<br>
# Source function library. 
<br>
. /etc/rc.d/init.d/functions 
<br>
<br>
# User under which tomcat will run 
<br>
TOMCAT_USER=tomcat 
<br>
<br>
RETVAL=0 
<br>
<br>
CATALINA_HOME='${CATALINA_HOME}' 
<br>
WORKER_ROOT='${WORKER_ROOT}' 
<br>
WORKER_LIST=( worker1 worker2 ) 
<br>
WORKER_PORT=( 8105 8205 ) 
<br>
WORKER_AJP_PORT=( 8109 8209 ) 
<br>
<br>
# start, debug, stop, and status functions 
<br>
start() { 
<br>
 i=$1 
<br>
 SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l` 
<br>
 if [ $SHUTDOWN_PORT -ne 0 ]; then 
<br>
 echo "Tomcat ${WORKER_LIST[i]} already started" 
<br>
 else 
<br>
 echo "Starting tomcat ${WORKER_LIST[i]}..." 
<br>
 CATALINA_BASE="$WORKER_ROOT/${WORKER_LIST[i]}" 
<br>
 su -l $TOMCAT_USER -c "export CATALINA_BASE=$CATALINA_BASE; $CATALINA_HOME/bin/startup.sh" 
<br>
 echo -n "Processing ..." 
<br>
 SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l` 
<br>
 while [ $SHUTDOWN_PORT -eq 0 ]; do 
<br>
 echo -n "..." 
<br>
 sleep 10 
<br>
 SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l` 
<br>
 done 
<br>
 echo " Done!" 
<br>
 echo "Tomcat ${WORKER_LIST[i]} started in normal mode" 
<br>
 RETVAL=$? 
<br>
 [ $RETVAL = 0 ] &amp;&amp; touch /var/lock/subsys/${WORKER_LIST[i]} /var/run/${WORKER_LIST[i]}.pid 
<br>
 fi 
<br>
} 
<br>
<br>
debug() { 
<br>
 i=$1 
<br>
 SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l` 
<br>
 if [ $SHUTDOWN_PORT -ne 0 ]; then 
<br>
 echo "Tomcat ${WORKER_LIST[i]} already started" 
<br>
 else 
<br>
 echo "Starting tomcat ${WORKER_LIST[i]} in debug mode..." 
<br>
 CATALINA_BASE="$WORKER_ROOT/${WORKER_LIST[i]}" 
<br>
 rm -rf $CATALINA_BASE/work/* 
<br>
<br>
 chown -R $TOMCAT_USER:$TOMCAT_USER $CATALINA_HOME 
<br>
 chown -R $TOMCAT_USER:$TOMCAT_USER $WORKER_ROOT 
<br>
 su -l $TOMCAT_USER -c "export CATALINA_BASE=$CATALINA_BASE; $CATALINA_HOME/bin/catalina.sh jpda start" 
<br>
 echo -n "Processing ..." 
<br>
 SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l` 
<br>
 while [ $SHUTDOWN_PORT -eq 0 ]; do 
<br>
 echo -n "..." 
<br>
 sleep 10 
<br>
 SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l` 
<br>
 done 
<br>
 echo " Done!" 
<br>
 echo "Tomcat ${WORKER_LIST[i]} started in debug mode" 
<br>
 RETVAL=$? 
<br>
 [ $RETVAL = 0 ] &amp;&amp; touch /var/lock/subsys/${WORKER_LIST[i]} /var/run/${WORKER_LIST[i]}.pid 
<br>
 fi 
<br>
} 
<br>
<br>
stop() { 
<br>
 i=$1 
<br>
 SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_AJP_PORT[i]}|wc -l` 
<br>
 if [ $SHUTDOWN_PORT -eq 0 ]; then 
<br>
 echo "Tomcat ${WORKER_LIST[i]} already stopped" 
<br>
 else 
<br>
 echo "Stopping tomcat ${WORKER_LIST[i]} ..." 
<br>
 CATALINA_BASE="$WORKER_ROOT/${WORKER_LIST[i]}" 
<br>
 su -l $TOMCAT_USER -c "export CATALINA_BASE=$CATALINA_BASE; $CATALINA_HOME/bin/shutdown.sh" 
<br>
 echo -n "Processing ..." 
<br>
 SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_AJP_PORT[i]}|wc -l` 
<br>
 while [ $SHUTDOWN_PORT -ne 0 ]; do 
<br>
 echo -n "..." 
<br>
 sleep 10 
<br>
 PROCESS_COUNT=`ps -ef|grep ${WORKER_LIST[i]}|grep -v grep|wc -l` 
<br>
 if [ $PROCESS_COUNT -ne 0 ]; then 
<br>
 kill -9 `ps -ef|grep ${WORKER_LIST[i]}|grep -v grep|awk '\'{print \$2}\''` 
<br>
 fi 
<br>
 SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_AJP_PORT[i]}|wc -l` 
<br>
 done 
<br>
 echo " Done!" 
<br>
 echo "Tomcat ${WORKER_LIST[i]} stopped" 
<br>
 RETVAL=$? 
<br>
 [ $RETVAL=0 ] &amp;&amp; rm -f /var/lock/subsys/${WORKER_LIST[i]} /var/run/${WORKER_LIST[i]}.pid 
<br>
 fi 
<br>
} 
<br>
<br>
status() { 
<br>
 for (( i = 0 ; i &lt; ${#WORKER_LIST[@]} ; i++ )) 
<br>
 do 
<br>
 SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_AJP_PORT[i]}|wc -l` 
<br>
 if [ $SHUTDOWN_PORT -eq 0 ]; then 
<br>
 echo "Tomcat ${WORKER_LIST[i]} stopped" 
<br>
 else 
<br>
 MODE="normal" 
<br>
 JPDA_PORT=`netstat -vatn|grep LISTEN|grep 8000|wc -l` 
<br>
 if [ $JPDA_PORT -ne 0 ]; then 
<br>
 MODE="debug" 
<br>
 fi 
<br>
 echo "Tomcat ${WORKER_LIST[i]} running in $MODE mode" 
<br>
 fi 
<br>
 done 
<br>
} 
<br>
<br>
case "$1" in 
<br>
 start) 
<br>
 start 0 
<br>
 start 1 
<br>
 ;; 
<br>
 debug) 
<br>
 debug 0 
<br>
 debug 1 
<br>
 ;; 
<br>
 stop) 
<br>
 stop 0 
<br>
 stop 1 
<br>
 ;; 
<br>
 restart) 
<br>
 stop 0 
<br>
 start 0 
<br>
 stop 1 
<br>
 start 1 
<br>
 ;; 
<br>
 redebug) 
<br>
 stop 0 
<br>
 debug 0 
<br>
 stop 1 
<br>
 debug 1 
<br>
 ;; 
<br>
 status) 
<br>
 status 
<br>
 ;; 
<br>
 *) 
<br>
 echo "Usage: $0 {start|debug|stop|restart|redebug|status}" 
<br>
 exit 1 
<br>
esac 
<br>
<br>
exit $RETVAL' &gt; /etc/rc.d/init.d/tomcat 
<br>
<br>
chmod 755 /etc/rc.d/init.d/tomcat 
<br>
/sbin/chkconfig --add tomcat 
<br>
/sbin/chkconfig --level 235 tomcat on 
<br>
<br>
echo '/sbin/chkconfig tomcat off' &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
echo '/sbin/chkconfig --del tomcat' &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
echo 'rm -rf /etc/rc.d/init.d/tomcat' &gt;&gt; ${SETUP_DIR}/cleanup.sh 
<br>
<br>
chmod 755 ${SETUP_DIR}/cleanup.sh 
<br>
<br>
echo 'Tomcat installation is completed!' 
<br>
echo 
<br>
echo 'You can type "/etc/init.d/tomcat start" to start using tomcat now.' 
<br>
echo 'You can type "/etc/init.d/httpd start" to start using apache now.' 
<br>
echo 'Open a browser, and go to http://'${hostname}' to see it.' 
<br>
<br>
# 
<br>
# modify web.xml for cluster test 
<br>
# 
<br>
sed -i -e "26a\ &lt;distributable/&gt;" ${WEBAPP_ROOT}/${hostname}/WEB-INF/web.xml 
<br>
<br>
# 
<br>
# generate clustertest.jsp for cluster test 
<br>
# 
<br>
echo '&lt;%@ page contentType="text/html; charset=UTF-8" import="java.util.*"%&gt; 
<br>
&lt;html&gt; 
<br>
&lt;head&gt; 
<br>
&lt;title&gt;Cluster Session Replication Test&lt;/title&gt; 
<br>
&lt;/head&gt; 
<br>
&lt;body&gt; 
<br>
&lt;% 
<br>
 out.println("Session ID=" + session.getId() + "&lt;br&gt;"); 
<br>
<br>
 String key = request.getParameter("key"); 
<br>
 if (key != null &amp;&amp; key.length() &gt; 0) { 
<br>
 String value = request.getParameter("value"); 
<br>
 session.setAttribute(key, value); 
<br>
 } 
<br>
<br>
 out.println("&lt;b&gt;Session Listing&lt;/b&gt;&lt;br&gt;"); 
<br>
<br>
 Enumeration e = session.getAttributeNames(); 
<br>
 while (e.hasMoreElements()) { 
<br>
 String name = (String) e.nextElement(); 
<br>
 String value = (String)session.getAttribute(name); 
<br>
 out.println(name + " = " + value + "&lt;br&gt;"); 
<br>
 } 
<br>
%&gt; 
<br>
<br>
 &lt;form method="post"&gt; 
<br>
 key:&lt;input type="text" size="20" name="key"&gt; 
<br>
<br>
 value:&lt;input type="text" size="20" name="value"&gt; 
<br>
<br>
 &lt;input type="submit"&gt; 
<br>
 &lt;/form&gt; 
<br>
&lt;/body&gt; 
<br>
&lt;/html&gt;' &gt; ${WEBAPP_ROOT}/${hostname}/clustertest.jsp 
<br>
[/code] 
<br>
<br>
4.Then you can use the following two commands to do step12 
<br>
service tomcat start 
<br>
service httpd start 
<br>
5. For testing, you can use the following command to shutdown or startup a single Tomcat worker: 
<br>
su -l tomcat -c "export CATALINA_BASE=/var/robust/worker1; /var/tomcat7/bin/shutdown.sh" 
<br>
su -l tomcat -c "export CATALINA_BASE=/var/robust/worker1; /var/tomcat7/bin/startup.sh" 
<br>
su -l tomcat -c "export CATALINA_BASE=/var/robust/worker2; /var/tomcat7/bin/shutdown.sh" 
<br>
su -l tomcat -c "export CATALINA_BASE=/var/robust/worker2; /var/tomcat7/bin/startup.sh" 
<br>
<br>
Or you may use a shell script to restart Tomcat repeatedly to verify if the session replication really works. 
<br>
[b]restart.sh[/b] 
<br>
[code] 
<br>
 for (( i = 0 ; i &lt; 10 ; i++ )) 
<br>
 do 
<br>
 service tomcat restart 
<br>
 done 
<br>
[/code] 
<br>
<br>
If you can see all of the session objects no matter how Tomcat is restarted, then Tomcat clustering(session replication) is done. 
<br>
<br>
Note: If you have enabled firewall like iptables, please add http(80:tcp), https(443:tcp) and [color=red]45564:udp[/color] port to the allowed list. 
<br>
<br>
6. Finally, browse https://&lt;your_server_ip&gt;/ to check SSL works. You have to add this site as your trust site because we use a self-signed SSL certificate. 
<br>
<br>
Reference: 
<br>
http://tomcat.apache.org/connectors-doc/reference/apache.html 
<br>
http://tomcat.apache.org/connectors-doc/generic_howto/loadbalancers.html 
<br>
http://tomcat.apache.org/tomcat-7.0-doc/cluster-howto.html 
<br>
http://tomcat.apache.org/tomcat-7.0-doc/jasper-howto.html 
<br>
http://tomcat.apache.org/tomcat-7.0-doc/logging.html 
<br>
http://www.easywayserver.com/tomcat-clustering.htm 
<br>
http://www.easywayserver.com/implementation-tomcat-clustering.htm]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/556/1151.page</guid>
				<link>https://forum.andowson.com/posts/preList/556/1151.page</link>
				<pubDate><![CDATA[Thu, 29 Sep 2011 17:29:54]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
			<item>
				<title>回覆:Apache 2.2 + SSL + JK 1.2 + Tomcat 7.0 Clustering Auto Installer for CentOS 5.6</title>
				<description><![CDATA[ Tomcat Connector Auto Upgrader 
<br>
tomcat-connector-upgrade.sh: 
<br>
[code=bash]#!/bin/bash 
<br>
# Name: Tomcat Connector 1.2.x auto-upgrade installer 
<br>
# Author: Andowson Chang (andowson [at] gmail [dot] com) 
<br>
# Version: 0.2 
<br>
# Since: 2007-03-17 
<br>
# Last Modified: 2011-07-16 
<br>
# 
<br>
# check the latest stable version of Tomcat Connector 1.2 
<br>
# 
<br>
TOMCAT_CONNECTOR_VERSION=1.2.32 
<br>
MIRROR_HOST=apache.ntu.edu.tw 
<br>
<br>
yum -y install httpd-devel apr-devel libtool automake make gcc gcc-c++ 
<br>
<br>
wget http://tomcat.apache.org/download-connectors.cgi -q -t 1 -T 5 -O /tmp/connector.html 
<br>
if [ -s /tmp/connector.html ]; then 
<br>
 TOMCAT_CONNECTOR_VERSION=`grep "1\.2\." /tmp/connector.html|cut -d"&gt;" -f2|cut -d"&lt;" -f1 |awk '{print $2}'|grep "1.2"|uniq` 
<br>
fi 
<br>
rm -rf /tmp/connector.html 
<br>
echo "Install Tomcat Connector JK ${TOMCAT_CONNECTOR_VERSION}" 
<br>
if [ ! -r tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz ]; then 
<br>
 wget http://${MIRROR_HOST}/tomcat/tomcat-connectors/jk/tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz 
<br>
fi 
<br>
tar zxvf tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz 
<br>
cd tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src/native 
<br>
./buildconf.sh 
<br>
./configure --with-apxs=/usr/sbin/apxs 
<br>
make 
<br>
/etc/init.d/httpd stop 
<br>
make install 
<br>
/etc/init.d/httpd start[/code]]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/477/1114.page</guid>
				<link>https://forum.andowson.com/posts/preList/477/1114.page</link>
				<pubDate><![CDATA[Sat, 16 Jul 2011 00:02:11]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
			<item>
				<title>回覆:Apache 2.2 + SSL + JK 1.2 + Tomcat 6.0 Clustering Auto Installer for CentOS 5.3</title>
				<description><![CDATA[ kevinwang72326您好: 
<br>
您可以自己試試看，如果有遇到問題，再把您的做法發表上來，讓大家討論。]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/315/1063.page</guid>
				<link>https://forum.andowson.com/posts/preList/315/1063.page</link>
				<pubDate><![CDATA[Thu, 9 Jun 2011 16:53:40]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
			<item>
				<title>回覆:Tomcat 虛擬主機管理（新增及刪除使用者和站台）</title>
				<description><![CDATA[ [quote=andowson]caramel您好： 
<br>
您可以參考這個連結上面的圖片及說明: 
<br>
http://www.easywayserver.com/implementation-tomcat-clustering.htm 
<br>
Vertical Clustering 
<br>
[img]http://www.easywayserver.com/images/implement/vertical.jpg[/img] 
<br>
[/quote] 
<br>
<br>
謝謝 我有按照這個方法把環境架設起來了 謝謝^^]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/309/1011.page</guid>
				<link>https://forum.andowson.com/posts/preList/309/1011.page</link>
				<pubDate><![CDATA[Wed, 18 May 2011 23:21:04]]> GMT</pubDate>
				<author><![CDATA[ caramel]]></author>
			</item>
			<item>
				<title>解決wget 檢查https連線時出現Certificate verification error: self signed certificate in certificate chain</title>
				<description><![CDATA[ 原本使用wget <a class="snap_shots" href="https://eip.mycomp.com" target="_blank">https://eip.mycomp.com</a> 會出現錯誤訊息，將Apache所在主機(eip.mycomp.com)之/etc/httpd/conf/ssl.crt/ca.crt複製到wget所在主機後，改用下列方式連線即可: 
<br>
wget --ca-certificate /path/to/ca.crt <a class="snap_shots" href="https://eip.mycomp.com" target="_blank">https://eip.mycomp.com</a>
<br>
參考資料: 
<br>
http://comments.gmane.org/gmane.comp.jakarta.repository/5996]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/482/1001.page</guid>
				<link>https://forum.andowson.com/posts/preList/482/1001.page</link>
				<pubDate><![CDATA[Tue, 3 May 2011 11:35:29]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
			<item>
				<title>強制將http導到https</title>
				<description><![CDATA[ 最近公司資安議題發燒，為了加強安全性，我們決定將整個網站都透過https傳輸方式讓使用者使用，而要達成這個自動強制將http導到https只要透過Apache的[url=http://httpd.apache.org/docs/current/mod/mod_rewrite.html]mod_rewrite[/url]機制，很輕鬆就可以達成，如下，在/etc/httpd/conf/httpd.conf內加入如下設定即可: 
<br>
<br>
[code]RewriteEngine On 
<br>
RewriteCond %{HTTPS} off 
<br>
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}[/code] 
<br>
<br>
然後重啟Apache 
<br>
[code]/etc/init.d/httpd restart[/code] 
<br>
<br>
[注意]如果您是看畫面自己打字輸入的人，要特別小心(這個小細節花了我好多時間才注意到): 
<br>
1.%{HTTP_HOST}和%{REQUEST_URI}中間沒有斜線('/') 
<br>
2.%{HTTP_HOST}和%{REQUEST_URI}是%開頭，不是$開頭 
<br>
<br>
參考資料: 
<br>
http://www.cyberciti.biz/tips/howto-apache-force-https-secure-connections.html 
<br>
<br>
相關文章: 
<br>
http://www.andowson.com/posts/list/315.page]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/474/983.page</guid>
				<link>https://forum.andowson.com/posts/preList/474/983.page</link>
				<pubDate><![CDATA[Mon, 28 Mar 2011 18:52:08]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
			<item>
				<title>回覆:在WIN7下使用JMS連結到WIN2008R2</title>
				<description><![CDATA[ 感謝大大的回文 
<br>
<br>
小弟用的是NETBEAN6.9版的JAVA工具 
<br>
引入的JAR檔有JMS.JAR和appserv-rt.jar 
<br>
這二個檔使用在客戶端 
<br>
<br>
大大給的資料真詳細 
<br>
謝謝呢 
<br>
最近又在忙其它的事 
<br>
小弟有空會再試試的 
<br>]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/461/948.page</guid>
				<link>https://forum.andowson.com/posts/preList/461/948.page</link>
				<pubDate><![CDATA[Wed, 5 Jan 2011 11:34:23]]> GMT</pubDate>
				<author><![CDATA[ jonathan1977]]></author>
			</item>
			<item>
				<title>解決WebLogic Server無法啟動問題： Unable to start WebLogic Server!! WebLogic: license error, Invalid host IP</title>
				<description><![CDATA[ 昨天幫主機啟動第二張網卡，設定了另一個IP，並修改了一下/etc/hosts，結果今天早上就收到一封信： 
<br>
<br>
[quote]$$$$$$$$$$$$$$$$ License Exception $$$$$$$$$$$$$$$$ 
<br>
<br>
<br>
Unable to start WebLogic Server!! 
<br>
WebLogic: license error, Invalid host IP 
<br>
<br>
<br>
$$$$$$$$$$$$$$$$ License Exception $$$$$$$$$$$$$$$$[/quote] 
<br>
<br>
把第二張網卡停用也無法重新啟動WebLogic Server，甚至把/etc/hosts回復成原來的樣子也起動不了。 :XD: 
<br>
後來上網搜尋了一下，找到這篇：[url]http://www.buildanddeploy.com/node/5[/url]，發現把主機IP移到/etc/hosts第一行，再重起WebLogic Server就成功了。 
<br>
<br>
<br>
<br>]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/446/912.page</guid>
				<link>https://forum.andowson.com/posts/preList/446/912.page</link>
				<pubDate><![CDATA[Sat, 16 Oct 2010 22:39:37]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
	</channel>
</rss>