The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows NT.
Apache Tomcat is the servlet container that is used in the official Reference Implementation for the java Servlet and JavaServer Pages technologies.
apache2.2 和tomcat6到www.apache.org官方網站下載。
tomcat 5 版本以后通過ajp13連接器(之前ajp12)與apache相連,tomcat ajp監控端口默認為8009。
以tomcat6.0為例,需要以下步驟:
從從tomcat.apache.org下載 連接器
1 下載連接器文件:
url(for win32): http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.26/mod_jk-1.2.26-httpd-2.2.4.so
url(for linux):
http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.26/x86_64/mod_jk-1.2.26-httpd-2.2.6.so
2 將下載的so文件放置到apachDir/modules目錄下
3 在apacheDir/conf目錄下新增workers.properties文件,並添加如下內容:
ps=\
workers.tomcat_home=D:\devtool\apache-tomcat-6.0.14
workers.java_home=C:\java\jdk1.5.0_11
worker.list=worker1,worker2
worker.worker1.port=8009
worker.worker1.host=127.0.0.1
worker.worker1.type=ajp13
worker.worker2.port=8009
worker.worker2.host=127.0.0.1
worker.worker2.type=ajp13
該文件中定義了2個worker,對應2個web應用,這里只指向同一個tomcat,實際中可以指向不同的機器或不同的端口。
3 修改apache的配置文件conf/httpd.conf:
找到最后一個LoadModule ,在下面添加:
LoadModule jk_module modules/mod_jk-1.2.26-httpd-2.2.4.so
JkWorkersFile F:/Apache2.2/conf/workers2.proerties
JkLogFile jklog.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the timestamp log format
JkLogStampFormat “[%a %b %d %H:%M:%S %Y] “
# Send servlet for context /examples to worker named worker1
# JkMount /examples/servlet/* worker1
# Send JSPs for context /examples to worker named worker1
#example webapp
JkMount /examples/* worker1
#statistic webapp
JkMount /statistic/* worker2
至此,設置結束,
重啟apache,打開tomcat6
我們試驗一下效果 :打開瀏覽器,地址欄輸入:http://localhost/examples/