快速配置Apache1.3.22 + Tomcat4.0.3

holen 2002-06-21 07:10:39
快速配置Apache1.3.22 + Tomcat4.0.3

一、准备工作

硬件:PC, 64M以上内存
软件环境:Win2000 + JDK1.4
相关软件:请到http://www.apache.org/下载Apache1.3.22 、Tomcat4.0.3、mod_jk.dll


二、一个实例

我需要建立一个项目,名叫annai,Apache和Tomcat安装在D盘,以下是我的安装步骤。

第一步:安装JDK1.4、Apache、Tomcat

JDK1.4默认安装在C:\j2sdk1.4.0。
Apache安装在D:\apache,Tomcat安装在D:\tomcat,这里最好不要用默认的路径,另外在安装Apache时,其中有一步我选择的是只给自己使用,即选第二项。

第二步:

在D:\tomcat\conf下新建目录jk,在jk目录下新建两个文件mod_jk.conf、workers.properties(这两个文件的内容参见附录)。
在D:\tomcat\webapps下建立目录annai,并在该目录下新建文件index.jsp,在index.jsp文件中写入语句<%=”Hello!”%>。
修改D:\tomcat\conf下server.xml文件,注释掉所有的Context内的内容,在此位置加入语句
<Context path="" docBase="annai" debug="0" privileged="true" />
OK,至此,Tomcat配置完毕!接下修改Apache。

将mod_jk.dll拷贝到D:\Apache\Apache\modules下,打开D:\Apache\Apache\conf下httpd.conf文件,在最后加入语句
Include d:/Tomcat/conf/jk/mod_jk.conf
接下来找到DocumentRoot,此行改为
DocumentRoot "D:/Tomcat/webapps/annai"
再找到<Directory …>项,此行改为
<Directory "D:/Tomcat/webapps/annai">
再找到DirectoryIndex,此行改为
DirectoryIndex index.html index.jsp
OK,Apache也配完了!


三、启动

进入D:\tomcat\bin,双击startup.bat,启动Tomcat,提示
Starting service Tomcat-Standalone
Apache Tomcat/4.0.3
Starting service Tomcat-Apache
Apache Tomcat/4.0.3
说明Tomcat启动成功。

进入D:\Apache\Apache,双击Apache.exe,提示
Apache/1.3.22 (Win32) mod_jk/1.1.0 running
说明Apache启动成功。

打开网页,在地址栏输入localhost,将输出
Hello!

一切OK,祝你成功!




附录:
mod_jk.conf 文件内容
#
# The following line instructs Apache to load the jk module
#
LoadModule jk_module modules/mod_jk.dll

JkWorkersFile "d:/tomcat/conf/jk/workers.properties"
JkLogFile "d:/tomcat/logs/mod_jk.log"

#
# Log level to be used by mod_jk
#
JkLogLevel error

#
# Root context mounts for Tomcat
#
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13

#########################################################
# Auto configuration for the /annai context starts.
#########################################################

#
# The following line makes apache aware of the location of the /annai context
#
Alias /annai "d:/Tomcat/webapps/annai"
<Directory "d:/Tomcat/webapps/annai">
Options Indexes FollowSymLinks
</Directory>

#
# The following line mounts all JSP files and the /servlet/ uri to tomcat
#
JkMount /annai/servlet/* ajp13
JkMount /annai/*.jsp ajp13

#
# The following line prohibits users from directly accessing WEB-INF
#
<Location "/annai/WEB-INF/">
AllowOverride None
deny from all
</Location>
#
# Use Directory too. On Windows, Location doesn't work unless case matches
#
<Directory "d:/Tomcat/webapps/annai/WEB-INF/">
AllowOverride None
deny from all
</Directory>

#
# The following line prohibits users from directly accessing META-INF
#
<Location "/annai/META-INF/">
AllowOverride None
deny from all
</Location>
#
# Use Directory too. On Windows, Location doesn't work unless case matches
#
<Directory "d:/Tomcat/webapps/annai/META-INF/">
AllowOverride None
deny from all
</Directory>

#######################################################
# Auto configuration for the /annai context ends.
#######################################################


workers.properties文件内容


#
# workers.tomcat_home should point to the location where you
# installed tomcat. This is where you have your conf, webapps and lib
# directories.
#
workers.tomcat_home=d:\tomcat

#
# workers.java_home should point to your Java installation. Normally
# you should have a bin and lib directories beneath it.
#
workers.java_home=C:\j2sdk1.4.0

#
# You should configure your environment slash... ps=\ on NT and / on UNIX
# and maybe something different elsewhere.
#
ps=\
# ps=/

#
#------ ADVANCED MODE ------------------------------------------------
#---------------------------------------------------------------------
#

#
#------ DEFAULT worket list ------------------------------------------
#---------------------------------------------------------------------
#
#
# The workers that your plugins should create and work with
#
worker.list=ajp13

#
#------ DEFAULT ajp13 WORKER DEFINITION ------------------------------
#---------------------------------------------------------------------
#

#
# Defining a worker named ajp13 and of type ajp13
# Note that the name and the type do not have to match.
#
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
# ----> lbfactor must be > 0
# ----> Low lbfactor means less work done by the worker.
worker.ajp13.lbfactor=1

#
# Specify the size of the open connection cache.
#worker.ajp13.cachesize

#
#------ DEFAULT LOAD BALANCER WORKER DEFINITION ----------------------
#---------------------------------------------------------------------
#

#
# The loadbalancer (type lb) workers perform wighted round-robin
# load balancing with sticky sessions.
# Note:
# ----> If a worker dies, the load balancer will check its state
# once in a while. Until then all work is redirected to peer
# workers.
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=ajp13



Holen (CJEA,中国JAVA工程师协会)
Holend@Yahoo.com
2002/6/21





...全文
67 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
松耦合紧内聚 2002-06-21
  • 打赏
  • 举报
回复
henhao
holen 2002-06-21
  • 打赏
  • 举报
回复
修改后的D:\tomcat\conf下server.xml文件(后段部分)
---------------------------------------------------------------



<!-- Tomcat Root Context -->
<!--
<Context path="" docBase="ROOT" debug="0"/>
-->

<!-- Tomcat Manager Context -->
<!--<Context path="/manager" docBase="manager"
debug="0" privileged="true"/>-->

<Context path="" docBase="annai"
debug="0" privileged="true" />



<!-- Tomcat Examples Context -->

<!-- <Context path="/examples" docBase="examples" debug="0"
reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_examples_log." suffix=".txt"
timestamp="true"/>
<Ejb name="ejb/EmplRecord" type="Entity"
home="com.wombat.empl.EmployeeRecordHome"
remote="com.wombat.empl.EmployeeRecord"/>
-->

<!-- PersistentManager: Uncomment the section below to test Persistent
Sessions.

saveOnRestart: If true, all active sessions will be saved
to the Store when Catalina is shutdown, regardless of
other settings. All Sessions found in the Store will be
loaded on startup. Sessions past their expiration are
ignored in both cases.
maxActiveSessions: If 0 or greater, having too many active
sessions will result in some being swapped out. minIdleSwap
limits this. -1 means unlimited sessions are allowed.
0 means sessions will almost always be swapped out after
use - this will be noticeably slow for your users.
minIdleSwap: Sessions must be idle for at least this long
(in seconds) before they will be swapped out due to
maxActiveSessions. This avoids thrashing when the site is
highly active. -1 or 0 means there is no minimum - sessions
can be swapped out at any time.
maxIdleSwap: Sessions will be swapped out if idle for this
long (in seconds). If minIdleSwap is higher, then it will
override this. This isn't exact: it is checked periodically.
-1 means sessions won't be swapped out for this reason,
although they may be swapped out for maxActiveSessions.
If set to >= 0, guarantees that all sessions found in the
Store will be loaded on startup.
maxIdleBackup: Sessions will be backed up (saved to the Store,
but left in active memory) if idle for this long (in seconds),
and all sessions found in the Store will be loaded on startup.
If set to -1 sessions will not be backed up, 0 means they
should be backed up shortly after being used.

To clear sessions from the Store, set maxActiveSessions, maxIdleSwap,
and minIdleBackup all to -1, saveOnRestart to false, then restart
Catalina.
-->
<!--
<Manager className="org.apache.catalina.session.PersistentManager"
debug="0"
saveOnRestart="true"
maxActiveSessions="-1"
minIdleSwap="-1"
maxIdleSwap="-1"
maxIdleBackup="-1">
<Store className="org.apache.catalina.session.FileStore"/>
</Manager>
-->

<!--
<Environment name="maxExemptions" type="java.lang.Integer"
value="15"/>
<Parameter name="context.param.name" value="context.param.value"
override="false"/>
<Resource name="jdbc/EmployeeAppDb" auth="SERVLET"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/EmployeeAppDb">
<parameter><name>user</name><value>sa</value></parameter>
<parameter><name>password</name><value></value></parameter>
<parameter><name>driverClassName</name>
<value>org.hsql.jdbcDriver</value></parameter>
<parameter><name>driverName</name>
<value>jdbc:HypersonicSQL:database</value></parameter>
</ResourceParams>
<Resource name="mail/Session" auth="Container"
type="javax.mail.Session"/>
<ResourceParams name="mail/Session">
<parameter>
<name>mail.smtp.host</name>
<value>localhost</value>
</parameter>
</ResourceParams>

</Context>-->

</Host>

</Engine>

</Service>

<!-- The MOD_WEBAPP connector is used to connect Apache 1.3 with Tomcat 4.0
as its servlet container. Please read the README.txt file coming with
the WebApp Module distribution on how to build it.
(Or check out the "jakarta-tomcat-connectors/webapp" CVS repository)

To configure the Apache side, you must ensure that you have the
"ServerName" and "Port" directives defined in "httpd.conf". Then,
lines like these to the bottom of your "httpd.conf" file:

LoadModule webapp_module libexec/mod_webapp.so
WebAppConnection warpConnection warp localhost:8008
WebAppDeploy examples warpConnection /examples/

The next time you restart Apache (after restarting Tomcat, if needed)
the connection will be established, and all applications you make
visible via "WebAppDeploy" directives can be accessed through Apache.
-->

<!-- Define an Apache-Connector Service -->
<Service name="Tomcat-Apache">

<Connector className="org.apache.catalina.connector.warp.WarpConnector"
port="8008" minProcessors="5" maxProcessors="75"
enableLookups="true" appBase="webapps"
acceptCount="10" debug="0"/>

<!-- Replace "localhost" with what your Apache "ServerName" is set to -->
<Engine className="org.apache.catalina.connector.warp.WarpEngine"
name="Apache" debug="0">

<!-- Global logger unless overridden at lower levels -->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="apache_log." suffix=".txt"
timestamp="true"/>

<!-- Because this Realm is here, an instance will be shared globally -->
<Realm className="org.apache.catalina.realm.MemoryRealm" />

</Engine>

</Service>

</Server>

62,636

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧