Apache2+Tomcat5.0.24+Mysql4.0

类别:Java 点击:0 评论:0 推荐:

1.       %apache2_home%/conf/Httpd.conf

DocumentRoot "D://tomcat5/webapps/ROOT"

<Directory "D:/tomcat5/webapps/ROOT">

#######AddDefaultCharset ISO-8859-1

AddDefaultCharset  GB2312

最后一行加入

LoadModule jk2_module modules/mod_jk2.so

-------------------------------------------------------------------------------------- 

2.       %apache2_home%/conf/workers2.properties

 

[shm]

file=d:/Apache2/Logs/shm.file

size=1048576

 

[channel.socket:localhost:8009]

port=8009

host=127.0.0.1

 

[ajp13:localhost:8009]

channel=channel.socket:localhost:8009

 

[uri:/*.jsp]

workers=ajp13:localhost:8009

 

  我试过worker=ajp.......似乎不可以

-------------------------------------------------------------------------- 

 

3.       %Tomcat5_home%/conf/jk2.properties

handler.list=apr,request,channelJni

# Override the default port for the socketChannel

 channelSocket.port=809

#

# shm.file=${jkHome}/work/jk2.shm

 

apr.jniModeSo=d:/apache2/modules/mod_jk2.so

 

# apr.jniModeSo=inprocess

 

shm.file=d:/Apache2/logs/jk2.shm

-------------------------------------------------------------------------------

4.环境变量设置

 

JAVA_HOME

D:\Program Files\Java\j2sdk1.4.2

CLASSPATH

.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%

JAVA_HOME%\jre\lib;%JAVA_HOME%\jre\lib\ext;%JAVA_HOME%\jre\lib\rt.jar;%

TOMCAT_HOME%\common\lib\mysql-connector-java.jar;%

TOMCAT_HOME%\common\lib

PATH

%JAVA_HOME%;%JAVA_HOME%\bin

TOMCAT_HOME

d:\Tomcat5

 

6.   jdbc连接mysql

Copy  mysql-connector-3.0-bin.jar(到www.mysql.org下载)到D:\tomcat5\common\lib下

 修改%tomcat5_Home%/conf/server.xml 寻找org.gjt.mm.mysql.Driver替换成 com.mysql.jdbc.Driver

copy县面 这段到server.xml </host>前 

-------------------------------------------------------------------------


<Context path="" docBase="ROOT"
        debug="5" reloadable="true" crossContext="true">

  <Logger className="org.apache.catalina.logger.FileLogger"
             prefix="localhost_DBTest_log." suffix=".txt"
             timestamp="true"/>

  <Resource name="jdbc/testDB"
               auth="Container"
               type="javax.sql.DataSource"/>

  <ResourceParams name="jdbc/testdb">
    <parameter>
      <name>factory</name>
      <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>

    <!-- Maximum number of dB connections in pool. Make sure you
         configure your mysqld max_connections large enough to handle
         all of your db connections. Set to 0 for no limit.
         -->
    <parameter>
      <name>maxActive</name>
      <value>10</value>
    </parameter>

    <parameter>
      <name>removeAbandoned</name>
      <value>true</value>
    </parameter>

 <parameter>
              <name>removeAbandonedTimeout</name>
              <value>60</value>
        </parameter>

    <!-- Maximum number of idle dB connections to retain in pool.
         Set to 0 for no limit.
         -->
    <parameter>
      <name>maxIdle</name>
      <value>30</value>
    </parameter>

    <!-- Maximum time to wait for a dB connection to become available
         in ms, in this example 10 seconds. An Exception is thrown if
         this timeout is exceeded.  Set to -1 to wait indefinitely.
         -->
    <parameter>
      <name>maxWait</name>
      <value>10000</value>
    </parameter>

    <!-- MySQL dB username and password for dB connections  -->
    <parameter>
     <name>username</name>
     <value>test</value>
    </parameter>
    <parameter>
     <name>password</name>
     <value>test</value>
    </parameter>

    <!-- Class name for mm.mysql JDBC driver -->
    <parameter>
       <name>driverClassName</name>
       <value>org.gjt.mm.mysql.Driver</value>
    </parameter>

    <!-- The JDBC connection url for connecting to your MySQL dB.
         The autoReconnect=true argument to the url makes sure that the
         mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
         connection.  mysqld by default closes idle connections after 8 hours.
         -->
    <parameter>
      <name>url</name>
      <value>jdbc:mysql://localhost:3306/testdb?autoReconnect=true</value>
    </parameter>
  </ResourceParams>
</Context>

--------------------------------------------------------------

 

Goog luck

 

本文地址:http://com.8s8s.com/it/it16366.htm