日期:2014-05-17  浏览次数:20976 次

apache与Tomcat整合配置文档[windows]


1\下载的软件(可以从此网址下载得到http://www.apache.org/dist/)
   apache_2.2.4-win32-x86-no_ssl.zip
   apache-tomcat-6.0.18.zip
   mod_jk-1.2.28-httpd-2.2.3.so(下载地址:http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/)
2\安装
a\pache_2.2.4-win32-x86-no_ssl  端口号8089
b\apache-tomcat-6.0.18          端口号8081
c\把mod_jk-1.2.28-httpd-2.2.3.so copy到apache的modules目录下面
d\在hosts文件中加入一行 127.0.0.1 webservice.test.com
e\并对apache与tomcat进行基本的设置

3\配置
假如站点目录是 d:\www\ROOT,包括静态文件与动态文件
apache配置
   两个文件:
       httpd.conf httpd-vhosts.conf

       1\ httpd.conf
          a\apache的基本配置
  b\增加workers.properties 文件保存在apache的conf目录下
      内容如下
       workers.tomcat_home=D:\Tomcat 6.0 #让mod_jk模块知道Tomcat的位置
workers.java_home=D:\Java\jdk1.6.0\jre #让mod_jk模块知道jre的位置
ps=\
worker.list=ajp13 #模块版本
worker.ajp13.port=8009 #工作端口,若没占用则不用修改
worker.ajp13.host=localhost #本机,若上面的Apache主机不为localhost,作相应修改
worker.ajp13.type=ajp13 #类型
worker.ajp13.lbfactor=1 #代理数,不用修改

  c\在httpd.conf文件结尾加上如下代码
     LoadModule jk_module modules\mod_jk-1.2.28-httpd-2.2.3.so
     JkWorkersFile "D:\Tomcat 6.0\conf\workers.properties"
       JkLogFile "D:\Tomcat 6.0\logs\mod_jk2.log"
     JkLogLevel info
             JkMount /*.jsp ajp13
     
      # 把JSPX程序映射到Jk连接器上
      JkMount /*.jspx ajp13
      # 把servlet程序映射到Jk连接器上
      JkMount /servlet/* ajp13
      JkMount /*.servlet ajp13

          d\httpd-vhosts.conf配置如下
   NameVirtualHost *:8089
   <VirtualHost *:8089>
    ServerAdmin webmaster@dummy-host.localhost
    DocumentRoot "D:/www/ROOT"
    ServerName webservice.test.com
    ServerAlias test
    ErrorLog "logs/dummy-host.localhost-error.log"
    CustomLog "logs/dummy-host.localhost-access.log" common
  </VirtualHost>

          
4\最后在ie中运行http://webservice.test.com:8089/index.jsp 与   http://webservice.test.com:8081/index.jsp      显示相同的内容表示配置成功


配置多虚拟主机(侦听一个端口的情况下)

补充

Listen 8089

  apache基本配置
    <Directory "D:/www">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # All