win 下整合 apache和tomcat, apache2.0.52;tomcat4.1.31

Win xp下Apache Server2.0.52+tomcat4.1.31+mod_jk.dll配置过程

首先就是软件下载的准备了,假设你的jdk已经安装了,我的版本是1.4.2_06

1、Apache Server 我的版本是2.0.52
2、tomcat 版本是 4.1.31
3、mod_jk.dll 版本是 mod_jk_1.2.6_2.0.50.dll
注意:这里的mod_jk.dll一定要下载2.0的,应为我们应用的Apache Server是2.0版本的,请大家不要下错了。

安装过程:

一、安装配置Apache HTTP
首先要确认你机器上的80端口没有被占用,如果有IIS web服务请先停掉(这个大家一般都知道,我就不在这里讲述了),然后安装Apache HTTP,在安装过程中,有一步骤是填写NetWork Domain和Server Name,这两项都填写localhost,email填写你自己的ok,
我的安装路径是D:/server/Apache2,注意中间没有空格,这一步很关键,请大家留意,其它步骤请按默认设置执行。
安装完毕后,在浏览器中访问 http://localhost
你应该看到apache的欢迎页面,表示apache server安装成功。

二、安装tomcat

按默认的步骤安装,我的安装路径是D:/server/Tomcat 4.1,安装之后访问 http://localhost:8080,应该可以看到tomcat的welcome page.

三、安装connectors

把文件mod_jk_1.2.6_2.0.50.dll拷贝到 D:/server/Apache2/modules/,并更名为mod_jk.dll。



配置过程:

1、找到D:/server/Tomcat 4.1/conf下面的server.xml,打开后,找到<Serverport="8005" shutdown="SHUTDOWN" debug="0">,在它的下面添加
<Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" modJk="D:/server/Apache2/modules/mod_jk.dll" />
往下面继续寻找
<Host ...>,在它的后面添加
<Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" append="true" forwardAll="false" modJk="D:/server/Apache2/modules/mod_jk.dll" />

2、打开D:/server/Apache2/conf下面的httpd.conf,在文件的末尾添加
Include "D:/server/Tomcat 4.1/conf/auto/mod_jk.conf"

3、在D:/Tomcat 4.1/conf目录下面新建两个目录auto和jk。

打开目录auto,新建一个文件mod_jk.conf,文件的内容如下:

CODE
########## Auto generated on Fri Oct 06 14:30:33 CST 2004##########

<IfModule !mod_jk.c>
  LoadModule jk_module D:/server/Apache2/modules/mod_jk.dll
</IfModule>

JkWorkersFile "D:/server/Tomcat 4.1/conf/jk/workers.properties"
JkLogFile "D:/server/Tomcat 4.1/logs/mod_jk.log"

JkLogLevel emerg



<VirtualHost localhost>
    ServerName localhost

#################### localhost:/admin ####################

    # Static files
    Alias /admin "D:/server/Tomcat 4.1/webapps/../server/webapps/admin"

    <Directory "D:/server/Tomcat 4.1/webapps/../server/webapps/admin">
        Options Indexes FollowSymLinks
        DirectoryIndex index.html index.htm index.jsp
    </Directory>


    # Deny direct access to WEB-INF and META-INF
    #
    <Location "/admin/WEB-INF/*">
        AllowOverride None
        deny from all
    </Location>

    <Location "/admin/META-INF/*">
        AllowOverride None
        deny from all
    </Location>
    #
    # Use Directory too. On Windows, Location doesn't work unless case matches
    #
    <Directory "D:/server/Tomcat 4.1/webapps/../server/webapps/admin/WEB-INF/">
        AllowOverride None
        deny from all
    </Directory>

    <Directory "D:/server/Tomcat 4.1/webapps/../server/webapps/admin/META-INF/">
        AllowOverride None
        deny from all
    </Directory>

    JkMount /admin/j_security_check  ajp13
    JkMount /admin/*.do  ajp13
    JkMount /admin/*.jsp  ajp13

################### localhost:/webdav ####################

    # Static files
    Alias /webdav "D:/server/Tomcat 4.1/webapps/webdav"

    <Directory "D:/server/Tomcat 4.1/webapps/webdav">
        Options Indexes FollowSymLinks
        DirectoryIndex index.jsp index.html index.htm
    </Directory>


    # Deny direct access to WEB-INF and META-INF
    #
    <Location "/webdav/WEB-INF/*">
        AllowOverride None
        deny from all
    </Location>

    <Location "/webdav/META-INF/*">
        AllowOverride None
        deny from all
    </Location>
    #
    # Use Directory too. On Windows, Location doesn't work unless case matches
    #
    <Directory "D:/server/Tomcat 4.1/webapps/webdav/WEB-INF/">
        AllowOverride None
        deny from all
    </Directory>

    <Directory "D:/Tomcat 4.1/webapps/webdav/META-INF/">
        AllowOverride None
        deny from all
    </Directory>

    JkMount /webdav/*.jsp  ajp13

#################### localhost:/examples ####################

    # Static files
    Alias /examples "D:/server/Tomcat 4.1/webapps/examples"

    <Directory "D:/server/Tomcat 4.1/webapps/examples">
        Options Indexes FollowSymLinks
        DirectoryIndex index.html index.htm index.jsp
    </Directory>


    # Deny direct access to WEB-INF and META-INF
    #
    <Location "/examples/WEB-INF/*">
        AllowOverride None
        deny from all
    </Location>

    <Location "/examples/META-INF/*">
        AllowOverride None
        deny from all
    </Location>
    #
    # Use Directory too. On Windows, Location doesn't work unless case matches
    #
    <Directory "D:/server/Tomcat 4.1/webapps/examples/WEB-INF/">
        AllowOverride None
        deny from all
    </Directory>

    <Directory "D:/server/Tomcat 4.1/webapps/examples/META-INF/">
        AllowOverride None
        deny from all
    </Directory>

    JkMount /examples/jsp/security/protected/j_security_check  ajp13
    JkMount /examples/snoop  ajp13
    JkMount /examples/servlet/*  ajp13
    JkMount /examples/CompressionTest  ajp13
    JkMount /examples/*.jsp  ajp13
    JkMount /examples/servletToJsp  ajp13
    JkMount /examples/SendMailServlet  ajp13

################# localhost:/tomcat-docs ####################

    # Static files
    Alias /tomcat-docs "D:/server/Tomcat 4.1/webapps/tomcat-docs"

    <Directory "D:/server/Tomcat 4.1/webapps/tomcat-docs">
        Options Indexes FollowSymLinks
        DirectoryIndex index.html index.htm index.jsp
    </Directory>


    # Deny direct access to WEB-INF and META-INF
    #
    <Location "/tomcat-docs/WEB-INF/*">
        AllowOverride None
        deny from all
    </Location>

    <Location "/tomcat-docs/META-INF/*">
        AllowOverride None
        deny from all
    </Location>
    #
    # Use Directory too. On Windows, Location doesn't work unless case matches
    #
    <Directory "D:/server/Tomcat 4.1/webapps/tomcat-docs/WEB-INF/">
        AllowOverride None
        deny from all
    </Directory>

    <Directory "D:/server/Tomcat 4.1/webapps/tomcat-docs/META-INF/">
        AllowOverride None
        deny from all
    </Directory>

    JkMount /tomcat-docs/*.jsp  ajp13

    #################### localhost:/manager ####################

    # Static files
    Alias /manager "D:/server/Tomcat 4.1/webapps/../server/webapps/manager"

    <Directory "D:/server/Tomcat 4.1/webapps/../server/webapps/manager">
        Options Indexes FollowSymLinks
        DirectoryIndex index.html index.htm index.jsp
    </Directory>


    # Deny direct access to WEB-INF and META-INF
    #
    <Location "/manager/WEB-INF/*">
        AllowOverride None
        deny from all
    </Location>

    <Location "/manager/META-INF/*">
        AllowOverride None
        deny from all
    </Location>
    #
    # Use Directory too. On Windows, Location doesn't work unless case matches
    #
    <Directory "D:/server/Tomcat 4.1/webapps/../server/webapps/manager/WEB-INF/">
        AllowOverride None
        deny from all
    </Directory>

    <Directory "D:/server/Tomcat 4.1/webapps/../server/webapps/manager/META-INF/">
        AllowOverride None
        deny from all
    </Directory>

    JkMount /manager/list  ajp13
    JkMount /manager/deploy  ajp13
    JkMount /manager/html/*  ajp13
    JkMount /manager/resources  ajp13
    JkMount /manager/start  ajp13
    JkMount /manager/stop  ajp13
    JkMount /manager/install  ajp13
    JkMount /manager/*.jsp  ajp13
    JkMount /manager/remove  ajp13
    JkMount /manager/roles  ajp13
    JkMount /manager/sessions  ajp13
    JkMount /manager/serverinfo  ajp13
    JkMount /manager/reload  ajp13
    JkMount /manager/undeploy  ajp13
</VirtualHost>


注意:上面这个文件在apache和tomcat启动后会自动更新,如果还有自己的应用程序,可添加。

打开目录jk,新建文件workers.properties,文件内容如下:

CODE
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13


保存以上两个文件。

首先启动 tomcat,然后重启apache server,浏览http://localhost/examples,如果不出意外的话,你应当看到tomcat的欢迎页面,ok配置成功!

你可能感兴趣的:(win 下整合 apache和tomcat, apache2.0.52;tomcat4.1.31)