http://blog.sina.com.cn/s/blog_4a7318860100b3b8.html
A 安裝JDK
# cd /usr/local/
# chmod +x jdk-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
export PATH JAVA_HOME CLASSPATH
B 安裝Apache
# cd /usr/local/
# tar xvfz httpd-2.0.54.tar.gz
# cd httpd-2.0.54
# ./configure --prefix=/usr/local/apache --enable-module=so
# make
# make install
# cd /usr/local/apache/conf
# vi ./httpd.conf
將Listen 80 修改為Listen 127.0.0.1:80 (219行)
將ServerName 修改為ServerName LocalHost:80 (291行)
在DirectoryIndex中添加 index.jsp (394行)
# cd /usr/local/apache/bin/
# ./apachectl configtest
顯示Syntax ok則表明安裝成功
#./apachectl start
啟動apache服務,浏覽器中訪問本機80端口,查看端口是否正常,輸入127.0.0.1:80
# ./apachectl stop
關閉服務
備注:prefix定義apache的安裝路徑
C安裝Tomcat
# cd /usr/local/
# tar xvfz jakarta-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/
# tar xzvf jakarta-tomcat-connectors-1.2.14-src.tar.gz
# cd jakarta-tomcat-connectors-1.2.14-src/jk/native
# chmod 755 buildconf.sh
# ./buildconf.sh
# ./configure --with-apxs=/usr/local/apache/bin/apxs
# make
# make install
# cd /usr/local/jakarta-tomcat-connectors-jk1.2.14-src/jk/native/apache-2.0/
# cp mod_jk.so /usr/local/apache/modules/
E 系統整合
# vi /usr/local/apache/conf/httpd.conf
在文件最末尾加上如下語句
#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 /*.jsp loadbalancer
JkMount /servlet/* loadbalancer
JkMount /application/* loadbalancer
#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" /> 第101行
在119行左右加入如下語句(去注釋)
<Engine name="Standalone" defaultHost="localhost" jvmRoute="tomcat1"></Engine>
若第二台tomcat,將jvmRoute的修改為tomcat2
系統整合完畢
啟動apache和tomcat服務
# /usr/local/apache/bin/apachectl start
# /usr/local/tomcat/bin/catalina.sh start
將如下內容添加至/etc/rc.d/rc.local文件末尾
以便系統啟動後開啟apache,tomcat服務
#vi /etc/rc.d/rc.local
添加
/usr/local/tomcat/bin/catalina.sh start
/usr/local/apache/bin/apachectl start