from :
http://java.chinaitlab.com/Tomcat/39607.html我的運行環境:Windows2003 Server SP4 + J2SDK1.5.0 + Apache2.0.54 + Tomcat5.5.9
??? **準備軟件:
??? 1、安裝 Apache 2.0.54
??? 2、Tomcat 5.5.14
??? 3、Jk2連接器(mod_jk2.so)
?
??? 一:配置Apache和tomcat
??? Apache安裝在d:\Apache2 下,監聽端口 80;
??? Tomcat在D:\Tomcat51 下,監聽端口 8080;
??? 兩者都以windows 2000服務進行安裝。
??? 將mod_jk2.so復制到d:\Apache2\modules目錄下:
?
??? 1.編輯d:\Apache2\conf\httpd.conf文件,在LoadModule那一段代碼中添加:
??? LoadModule jk2_module modules/mod_jk2.so
?
??? 2.將AddDefaultCharset ISO-8859-1 改為 AddDefaultCharset GB2312 使Apache自動支持中文顯示;
?
??? 3.在“虛擬主機配置代碼段”中添加:(此段配置可以根據你的實際情況進行修改)
? <VirtualHost *:80>
??? ServerAdmin linvsfen◎163.com
??? DocumentRoot "d:/ Tomcat51/webapps/jsp-examples
??? ServerName localhost
??? ErrorLog logs/error_log
??? CustomLog logs/access_log common
? </VirtualHost>
??? **編寫workers2.properties文件并加入d:\Apache2\conf目錄,內容如下:
???
? # Usually commented out on production environments
[logger.apache2]
file=”D:/Apache2/logs/error.log”
level=ERROR
# Provide the basic config needed
[config]
file=D:/Apache2/conf/workers2.properties
debug=1
# Provide the location of shm file on the Apache web server
[shm]
file=D:/Apache2/conf/jk2.shm
size=1000000
[channel.socket:localhost:8009]
port=8009
host=localhost
#define the worker
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
# Map the Tomcat examples webapp to the Web server uri space
[uri:/jsp-examples/*]
[uri:/*.jsp]
??? **編寫一個jsp文件(sessiontest.jsp),放在d:\Tomcat51\webapps\jsp-examples 下;
??? 重新啟動以后,啟動apache和tomcat,訪問http://localhost/jsp-examples/sessiontest.jsp可以訪問。
??? 二.Tomcat配置上ssl步驟:
??? 1.??? 生成服務器證書server02.jks和客戶端證書dwp.p12
??? 2、把server02.jks放到conf目錄下,
??? 打開d:\ tomcat51\conf\server.xml 文件,
??? 然后修改server.xml文件,將注釋掉的內容的注釋去掉和增加證書存放的位置:如下:
<Connector???? port="8443" maxHttpHeaderSize="8192"
?????????????? maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
?????????????? enableLookups="false" disableUploadTimeout="true"
?????????????? acceptCount="100" scheme="https" secure="true"
?????????????? clientAuth="true" sslProtocol="TLS"
?????????????? keystoreFile="conf\server02.jks"???? keystorePass="123456"
????????????? truststoreFile="conf\server02.jks" truststorePass="123456"/>
??? 注:server02.jks是證書存貯文件
??? 3. 安裝客戶端證書dwp.p12
??? 3. 修改Tomcat配置,使其自動啟用SSL
???
??? 打開d:\test\tomcat51\webapps\jsp-examples\WEB_INF\web.xml 文件,在security-constraint 標簽下,增加如下內容:
??? <user-data-constraint>
????? <description>
???????? Constrain the user data transport for the whole application
????? </description>
????? <transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
?注釋掉<auth-constraint>標簽下的內容
<auth-constraint>
???????? <!-- Anyone with one of the listed roles may access this area -->
???????? <role-name>tomcat</role-name>
???? <role-name>role1</role-name>
????? </auth-constraint>
在web-resource-collection 標簽下,增加如下內容:
????? <url-pattern>/*</url-pattern>
??? 重新啟動Apache和tomcat,
?
??? 訪問 http://localhost/jsp-examples/sessiontest.jsp是可是訪問的,這是系統提示用戶出示證書,啟用SSL加密通道,SSL建立后,返回結果。URL變為https://localhost:8443/jsp-examples/sessiontest.jsp
地震讓大伙知道:居安思危,才是生存之道。
posted on 2007-03-11 11:19
小尋 閱讀(219)
評論(0) 編輯 收藏