Linux系统Jsp的环境:Apache,Tomcat配置linux tomcat环境配置




Linux系统Jsp的环境:Apache,Tomcat配置linux tomcat环境配置

2022-07-20 21:06:48 网络知识 官方管理员

1.操作系统

RedHatLinux9.0

2.所需软件

Apache2.0.54

下载地址

http://apache.freelamp.com/httpd

下载该文件httpd-2.0.54.tar.gz

Tomcat5.5.9

下载地址

http://apache.justdn.org/jakarta/tomcat-5/v5.5.9/bin/

下载该文件jakarta-tomcat-5.5.9.tar.gz

Mod_jk1.2.14

下载地址

http://apache.justdn.org/jakarta/tomcat-connectors/jk/source/jk-1.2.14/

下载该文件jakarta-tomcat-connectors-1.2.14-src.tar.gz

Jdk1_5_0_04

下载地址

http://java.sun.com/j2se/1.5.0/download.jsp

下载该文件jdk-1_5_0_04-linux-i586-rpm.bin

下载时将所需软件包文件保存在/usr/local目录下

3.安装步骤

A安装JDK

#cd/usr/local/

#chmod+xjdk-1_5_0_04-linux-i586-rpm.bin

#./jdk-1.5.0_04-linux-i586-rpm.bin

#cd/usr/java/

#ln-s/usr/java/jdk-1_5_0_04/usr/local/java

#vi/etc/profile

#

添加如下内容

JAVA_HOME=/usr/java/jdk-1_5_0_04

CLASSPATH=/usr/java/jdk-1_5_0_04/lib/dt.jar:/usr/java/jdk-1_5_0_04/lib/tools.jar

PATH=/usr/java/jdk-1_5_0_04/bin: $PATH

exportPATHJAVA_HOMECLASSPATH

B安装Apache

#cd/usr/local/

#tarxvfzhttpd-2.0.54.tar.gz

#cdhttpd-2.0.54

#./configure--prefix=/usr/local/apache--enable-module=so

#make

#makeinstall

#cd/usr/local/apache/conf

#vi./httpd.conf

将Listen80修改为Listen127.0.0.1:80 (219行)

将ServerName修改为ServerNameLocalHost:80(291行)

在DirectoryIndex中添加index.jsp(394行)

#cd/usr/local/apache/bin/

#./apachectlconfigtest

显示Syntaxok则表明安装成功

#./apachectlstart

启动apache服务,浏览器中访问本机80端口,查看端口是否正常,输入127.0.0.1:80

#./apachectlstop

关闭服务

备注:prefix定义apache的安装路径

C安装Tomcat

#cd/usr/local/

#tarxvfzjakarta-tomcat-5.5.9.tar.gz

#ln?s/usr/local/jakarta-tomcat-5.5.9 /usr/local/tomcat

#vi/usr/local/tomcat/bin/catalina.sh

第46行加入此句

JAVA_HOME=/usr/java/jdk-1_5_0_04

启动服务后,访问本机8080端口,查看端口是否正常(输入127.0.0.1:8080)

#/usr/local/tomcat/bin/startup.sh/startup.bat

关闭服务

#/usr/local/tomcat/bin/shutdown.sh/shutdown.bat

D安装JK

#cd/usr/local/

#tarxzvfjakarta-tomcat-connectors-1.2.14-src.tar.gz

#cdjakarta-tomcat-connectors-1.2.14-src/jk/native

#chmod755buildconf.sh

#./buildconf.sh

#./configure--with-apxs=/usr/local/apache/bin/apxs

#make

#makeinstall

#cd/usr/local/jakarta-tomcat-connectors-jk1.2.14-src/jk/native/apache-2.0/

#cpmod_jk.so/usr/local/apache/modules/

E系统整合

#vi/usr/local/apache/conf/httpd.conf

在文件最末尾加上如下语句

#Loadmod_jk

LoadModulejk_modulemodules/mod_jk.so

#Configuremod_jk

JkWorkersFileconf/workers.properties

JkLogFilelogs/mod_jk.log

JkLogLevelinfo

JkMount/*.jsploadbalancer

JkMount/servlet/*loadbalancer

JkMount/application/*loadbalancer

#vi/usr/local/apache/conf/workers.properties

添加下列语句

#

#workers.properties

#

#InUnix,weuseforwardslashes:

ps=/

#listtheworkersbyname

worker.list=tomcat1,tomcat2,loadbalancer

#------------------------

#Firsttomcatserver

#------------------------

worker.tomcat1.port=8009

worker.tomcat1.host=127.0.0.1

worker.tomcat1.type=ajp13

#Specifythesizeoftheopenconnectioncache.

#worker.tomcat1.cachesize

#

#Specifiestheloadbalancefactorwhenusedwith

#aloadbalancingworker.

#Note:

#---->lbfactormustbe>0

#---->Lowlbfactormeanslessworkdonebytheworker.

worker.tomcat1.lbfactor=100

#------------------------

#Secondtomcatserver

#------------------------

worker.tomcat2.port=8009

worker.tomcat2.host=192.168.1.34

worker.tomcat2.type=ajp13

#Specifythesizeoftheopenconnectioncache.

#worker.tomcat2.cachesize

#

#Specifiestheloadbalancefactorwhenusedwith

#aloadbalancingworker.

#Note:

#---->lbfactormustbe>0

#---->Lowlbfactormeanslessworkdonebytheworker.

worker.tomcat2.lbfactor=100

#------------------------

#LoadBalancerworker

#------------------------

#Theloadbalancer(typelb)workerperformsweightedround-robin

#loadbalancingwithstickysessions.

#Note:

#---->Ifaworkerdies,theloadbalancerwillcheckitsstate

#onceinawhile.Untilthenallworkisredirectedtopeer

#worker.

worker.loadbalancer.type=lb

worker.loadbalancer.balanced_workers=tomcat1,tomcat2

#

#ENDworkers.properties

#

#vi/usr/local/tomcat/conf/server.xml

protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"

redirectPort="8443"protocol="AJP/1.3"/> 第101行

在119行左右加入如下语句(去注释)

若第二台tomcat,将jvmRoute的修改为tomcat2

系统整合完毕

启动apache和tomcat服务

#/usr/local/apache/bin/apachectlstart

#/usr/local/tomcat/bin/catalina.shstart

将如下内容添加至/etc/rc.d/rc.local文件末尾

以便系统启动后开启apache,tomcat服务

#vi/etc/rc.d/rc.local

添加

/usr/local/tomcat/bin/catalina.shstart

/usr/local/apache/bin/apachectlstart


发表评论:

最近发表
网站分类
标签列表