linux下apache與tomcat整合問題~~

火星人 @ 2014-03-03 , reply:0


linux下apache與tomcat整合問題~~

linux下apache與tomcat整合問題~~


我知道論壇上有許多優秀的apache和tomcat整合的文章。我也是按照高手的配置文檔進行配置的,之前配置非常順利,只是到了apache與tomcat整合時出現了問題。

過程如下:

系統:redhat 5.4 i386
安裝所需的程序庫
yum -y install gcc* autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses* curl*

apr-1.4.2.tar.gz
tar zxvf apr-1.4.2.tar.gz
cd apr-1.4.2
./configure --prefix=/usr/local/apr
make&&make install

apr-util-1.3.10.tar.gz
tar zxvf apr-util-1.3.10.tar.gz
cd apr-util-1.3.10
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
make&&make install

httpd-2.2.11.tar.gz
tar zxvf httpd-2.2.11.tar.gz
cd httpd-2.2.11
./configure --prefix=/usr/local/apache2 --enable-modules=so --enable-so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
make&&make install
/usr/local/apache2/bin/apachectl start
netstat -tan | grep 80
/usr/local/apache2/bin/apachectl stop

jdk-6u30-linux-i586-rpm.bin
cp jdk-6u30-linux-i586-rpm.bin /usr/local/
cd /usr/local/
chmod +x jdk-6u30-linux-i586-rpm.bin
./jdk-6u7-linux-i586-rpm.bin

java -version
# java -version
java version "1.4.2"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) Client VM (build 20.5-b03, mixed mode, sharing)

vi /etc/profile
##
export JAVA_HOME=/usr/java/jdk1.6.0_30
export PATH=$JAVA_HOME/binPATH
export CLASSPATH=$JAVA_HOME/lib/dt.jarJAVA_HOME/lib/tools.jar
export TOMCAT_HOME=/usr/local/tomcat
##
:x

運行以下命令激活配置:
source /etc/profile

# ln -s /usr/java/jdk1.6.0_30/ /usr/local/jdk
# ln -s /usr/java/jdk1.6.0_30/jre/ /usr/local/jre

# java -version
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) Client VM (build 20.5-b03, mixed mode, sharing)

tar zxvf apache-tomcat-7.0.8.tar.gz
mv apache-tomcat-7.0.8 /usr/local/tomcat

cd /usr/local/tomcat/bin/
./startup.sh
netstat -tan | grep 8080
./shutdown.sh

tomcat-connectors-1.2.28-src.tar.gz JK 安裝
tar zxvf tomcat-connectors-1.2.28-src.tar.gz
cd tomcat-connectors-1.2.28-src/native/
./configure --with-apxs=/usr/local/apache2/bin/apxs --with-java-home=/usr/local/jdk
make&&make install

接下來進行apache與tomat整合
cd /usr/local/apache2/conf
vi  httpd.conf
添加 (插入到httpd.conf的第54行)
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties   JK配置文件 負載的配置
JkShmFile logs/mod_jk.shm
JkLogFile logs/mod_jk.log  相關日誌的設置
JkLogLevel info
JkMount /*.jsp controller  將jsp的請求轉發給 controller(負載均衡控制器)
:x

vi workers.properties   
# workers.properties

# list the workers by name

worker.list=DLOG4J, status

# localhost server 1
# ------------------------
worker.s1.port=8109
worker.s1.host=localhost
worker.s1.type=ajp13

# localhost server 2
# ------------------------
worker.s2.port=8209
worker.s2.host=localhost
worker.s2.type=ajp13
worker.s2.stopped=1

worker.DLOG4J.type=lb
worker.retries=3
worker.DLOG4J.balanced_workers=s1, s2
worker.DLOG4J.sticky_session=1

worker.status.type=status
:x

或者 vi  workers.properties   
worker.list=worker1
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.woker1.lbfactor=1
:x

啟動tomcat:
/usr/local/tomcat/bin/startup.sh
netstat -tan | grep 8080
啟動成功

啟動httpd:
# /usr/local/apache2/bin/apachectl start
Syntax error on line 55 of /usr/local/apache2/conf/httpd.conf:
JkWorkersFile takes one argument, The name of a worker file for the Tomcat servlet containers

從網上了解到,這裡的意思是httpd.conf 的第55行有語法錯誤,說的就是JkWorkersFile conf/workers.properties   這一行存在語法錯誤,但是網上大部分文檔都是這麼配置的,而且可以正常運行,這個問題已經困擾我好久了,今天實在想不出來了才發帖的,希望能夠得到大家的幫助,謝謝!!
《解決方案》

謝謝分享
《解決方案》

謝謝分享




[火星人 via ] linux下apache與tomcat整合問題~~已經有292次圍觀

http://www.coctec.com/docs/service/show-post-1091.html