1. 操作系統(tǒng)
RedHat Linux AS 4
2. 所需軟件
httpd-
jakarta-tomcat-
tomcat-connectors-
j2sdk-1_4_2_15-linux-i586-rpm.bin
備注:下載時(shí)將所需軟件包文件保存在/usr/local目錄下
3. 安裝步驟
先安裝JDK和TOMCAT;
A 安裝Apache
# cd /usr/local/
# tar xvfz httpd-
# cd httpd-
#./configure --prefix=/usr/local/apache --enable-module=so
# make
# make install
# cd /usr/local/apache/conf
# vi ./httpd.conf
將Listen 80 修改為Listen :80
將ServerName 修改為ServerName :80
# cd /usr/local/apache/bin/
# ./apachectl configtest
若顯示Syntax ok則表明安裝成功
#./apachectl start
啟動(dòng)apache服務(wù),訪問(wèn)本機(jī)80端口,查看端口是否正常
# ./apachectl stop
關(guān)閉服務(wù)
備注:prefix定義apache的安裝路徑
B 安裝JK
#cd /usr/local/
# tar xzvf tomcat-connectors-
#cd tomcat-connectors-
#chmod 755 buildconf.sh
#./buildconf.sh
#./configure --with-apxs=/usr/local/apache/bin/apxs
#make
#make install
#cd /usr/local/tomcat-connectors-
#cp mod_jk.so /usr/local/apache/modules/
C 系統(tǒng)整合
#vi /usr/local/apache/conf/httpd.conf
在文件最末尾加上如下語(yǔ)句
# Load mod_jk
LoadModule jk_module modules/mod_jk.so
# Configure mod_jk
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkMount /* loadbalancer
增加workers.properties文件:
# vi /usr/local/apache/conf/workers.properties
#
# workers.properties
#
# In Unix, we use forward slashes:
ps=/
# list the workers by name
worker.list=tomcat1, tomcat2, loadbalancer
# ------------------------
# First tomcat server
# ------------------------
worker.tomcat1.port=8009
worker.tomcat1.host=127.0.0.1
worker.tomcat1.type=ajp13
# Specify the size of the open connection cache.
#worker.tomcat1.cachesize
#
# 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.tomcat1.lbfactor=100
# ------------------------
# Second tomcat server
# ------------------------
worker.tomcat2.port=8009
worker.tomcat2.host=192.168.1.34
worker.tomcat2.type=ajp13
# Specify the size of the open connection cache.
#worker.tomcat2.cachesize
#
# 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.tomcat2.lbfactor=100
# ------------------------
# Load Balancer worker
# ------------------------
# The loadbalancer (type lb) worker performs weighted 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
# worker.
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=tomcat1, tomcat2
#
# END workers.properties
#
#vi /usr/local/tomcat/conf/server.xml
<Connector port="8009"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"
redirectPort="8443" protocol="AJP/1.3" />
在120行左右加入如下語(yǔ)句
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1"></Engine>
若第二臺(tái)tomcat,將jvmRoute的修改為tomcat2
集群配置:
將兩中tomcat服務(wù)器的/usr/local/tomcat/conf/server.xml中<Cluster>元素的注澤去掉。
至此,系統(tǒng)已經(jīng)整個(gè)完畢
啟動(dòng)apache和tomcat服務(wù)
# /usr/local/apache/bin/apachectl start
#/usr/local/tomcat/bin/catalina.sh start
設(shè)置自動(dòng)啟動(dòng):
將如下內(nèi)容添加至/etc/rc.d/rc.local文件末尾,以便系統(tǒng)啟動(dòng)后開(kāi)啟apache,tomcat服務(wù)
/usr/local/tomcat/bin/catalina.sh start
/usr/local/apache/bin/apachectl start
聯(lián)系客服