hhyy安装Linux9+httpd-2.0.52+tomcat-5.0.28+mod_jk2步骤
2004-10-28
所需安装包(latest version):
j2sdk-1_4_2_06-linux-i586.bin
httpd-2.0.52.tar.gz
jakarta-tomcat-5.0.28.tar.gz
jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz
额外安装包:
apr-1.0.0.tar.gz
apr-util-1.0.0.tar.gz
libtool-1.5.6.tar.gz (or the latest version 1.5.10 from http://www.gnu.org/software/libtool/)
安装目录:
j2sdk --> /usr/local/j2sdk
apache --> /usr/local/apache2
tomcat --> /usr/local/tomcat
1.安装J2sdk1.4.2 , tomcat的运行需要j2sdk支持。
下载地址:http://java.sun.com/j2se/1.4.2/download.html
cp /path/to/j2sdk-1_4_2_06-linux-i586.bin /usr/local/
cd /usr/local
chmod +x j2sdk-1_4_2_06-linux-i586.bin
./j2sdk-1_4_2_06-linux-i586.bin
ln -s j2sdk1.4.2_06 j2sdk
2.设置环境变量,java的运行需要设置一下环境变量。
在/etc/profile中设置如下参数:
JAVA_HOME=/usr/local/j2sdk
CLASSPATH=$JAVA_HOME/lib/tools.jar
PATH=$PATH:$JAVA_HOME/bin
LANG=zh_CN.GBK
LC_ALL=zh_CN.GBK
并且export它们。
修改原来的export语句为:
export JAVA_HOME CLASSPATH LANG LC_ALL PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
若要立即生效,在shell下边依次执行一遍上边的语句。
输入java -version能看到版本信息,即安装j2sdk成功了。
3.安装Aapache.
必须编译成允许动态加载模块的方式,即在configure时要加--enable-so选项,以便加载mod_jk2.so这个整合模块。
wget http://apache.intissite.com/httpd/httpd-2.0.52.tar.gz
tar zxvf httpd-2.0.52.tar.gz
./configure --prefix=/usr/local/apache2 --enable-module=most --enable-shared=max --enable-so
make
make install
4.安装Tomcat,最简单是下载binary版本,直接tar -xzvf jakarta-tomcat-x.x.x 即可。
下载地址:http://jakarta.apache.org/site/binindex.cgi
wget http://apache.247available.com/jakarta/tomcat-5/v5.0.28/bin/jakarta-tomcat-5.0.28.tar.gz
tar zxvf jakarta-tomcat-5.0.28.tar.gz
cp -R jakarta-tomcat-5.0.28 /usr/local
ln -s jakarta-tomcat-5.0.28 tomcat
测试tomcat是否正常:
启动tomcat服务:/usr/local/tomcat/bin/startup.sh
访问 http://ip:8080 是否看到tomcat页面
关闭:/usr/local/tomcat/bin/shutdown.sh
5.tomcat-connectors 用来整合apache和tomcat,编译生成mod_jk2.so模块,apache加载之后,就能将不属于自己的请求转发给tomcat。
***所有步骤中,这步最为复杂。***
选择从source编译生成最符合自己环境的mod_jk2.so ,如果编译不成功,但是大致环境是Redhat DS3,apache2,tomcat4/5的,
可以跟我要一个mod_jk2.so,拷贝在/usr/local/apache2/modules/下就ok。
下载地址:http://apache.osuosl.org/jakarta/tomcat-connectors/jk2/
wget http://apache.osuosl.org/jakarta/tomcat-connectors/jk2/source/jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz
tar zxvf jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz
cd jakarta-tomcat-connectors-jk2-2.0.4-src/
cd jk/native2
#make clean
./configure --with-apxs2=/usr/local/apache2/bin/apxs
make
不出问题的话:
cd ../build/jk2/apache2/
这里会有一个mod_jk2.so,拷贝到/usr/local/apache2/modules目录下。
cp mod_jk2.so /usr/local/apache2/modules/
------------------------------
如果configure通不过,提示:
need to check for Perl first, apxs depends on it...
checking for perl... /usr/bin/perl
configure: error: can't locate libapr
则需安装libapr和libaprutil
wget http://apache.osuosl.org/apr/apr-1.0.0.tar.gz
wget http://apache.osuosl.org/apr/apr-util-1.0.0.tar.gz
tar zxvf apr-1.0.0.tar.gz
cd apr-1.0.0
./configure
make
make install
tar zxvf apr-util-1.0.0.tar.gz
cd apr-util-1.0.0
./configure --with-apr=../apr-1.0.0
make
make install
cd /usr/local/apache2/lib/
ln -s /usr/local/apr/lib/libapr-1.so.0.0.0 libapr-1.so
ln -s /usr/local/apr/lib/libapr-1.so.0.0.0 libapr-1.so.0
ln -s /usr/local/apr/lib/libaprutil-1.so.0.0.0 libaprutil-1.so
ln -s /usr/local/apr/lib/libaprutil-1.so.0.0.0 libaprutil-1.so.0
------------------------------
如果make通不过,/path/to/jakarta-tomcat-connectors-jk2-2.0.4-src/jk/build/jk2/apache2目录下并无mod_jk2.so产生,则需安装新版libtool。
redhat ADS 3自带的libtool是
[root@test apache2]# libtool --version
ltmain.sh (GNU libtool) 1.4.3 (1.922.2.111 2002/10/23 02:54:36
这个版本的libtool编译最新的
jakarta-tomcat-connectors-jk2-2.0.4-src
是不会成功的。
wget http://ftp.gnu.org/gnu/libtool/libtool-1.5.6.tar.gz
tar zxvf libtool-1.5.6.tar.gz
cd libtool-1.5.6
make
make install
[root@test apache2]# /usr/local/bin/libtool --version
ltmain.sh (GNU libtool) 1.5.6 (1.1220.2.94 2004/04/10 16:27:27)
ln -s /usr/local/bin/libtool /usr/local/apache2/build/libtool
再configure,make就ok了。
6.配置:
修改/usr/local/apache2/conf/httpd.conf
DocumentRoot "/var/www/html"
<Directory />
Options None
AllowOverride None
Order deny,Allow
Allow from all
</Directory>
<Directory "/var/www/html">
Options Includes FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
XBitHack on
</Directory>
LoadModule jk2_module modules/mod_jk2.so
DirectoryIndex index.htm index.jsp index.html
<Directory "/var/www/html/WEB-INF">
Deny from all
</Directory>
创建/usr/local/apache2/conf/workers2.properties,内容如下:
[logger]
level=ERROR
[config:]
file=/usr/local/apache2/conf/workers2.properties
debug=0
debugEnv=0
# Alternate file logger
[logger.file]
#level=DEBUG
level=ERROR
file=/var/log/httpd/jk2.log
[shm:]
info=Scoreboard. Required for reconfiguration and status with multiprocess servers
file=/var/log/httpd/jk2.shm
size=1048576
debug=0
disabled=0
[channel.socket:localhost:8009]
info=Ajp13 forwarding over socket
debug=0
tomcatId=localhost:8009
keepalive=1
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
debug=0
[status:]
info=Status worker, displays runtime informations
[uri:/jkstatus/*]
info=Display status information and checks the config file for changes.
worker=ajp13:localhost:8009
[uri:/*.jsp]
worker=ajp13:localhost:8009
context=/
修改/usr/local/tomcat/conf/server.xml
在
<Host name="localhost" debug="0" appBase="apps"
unpackWARs="true" autoDeploy="true">
段中添加:
<Context path="" docBase="/var/www/html" debug="0"
reloadable="true" crossContext="true"/>
保存退出。
7.测试:
在/var/www/html/下创建test.jsp,
内容:
<%@ page import="java.util.*,java.sql.*,java.text.*" contentType="text/html;charset=gb2312" %>
<%
out.println("test page");
%>
访问http://IP/test.jsp,内容正常则说明connector正常。
至此配置全部完成。
======================
hhyy007@hotmail.com
syncml 回复于:2004-10-30 17:04:28 |
我严格按照这个步骤执行了,可是test.jsp出来的确实源码,郁闷阿,谁知道怎么回事呢? |
hhyy 回复于:2004-11-01 11:07:42 |
出来源码,你的mod_jk2.so可能有点问题吧,如果需要,我可以把我的mod_jk2.so文件给你。 |
fxkh 回复于:2004-11-02 16:57:30 |
请问workers2.properties文件是做什么用 |
xhy1026 回复于:2004-11-07 15:40:39 |
workers2.properties这个文件的内容看得人晕晕的~~
楼主能解释下啊 |
fmsm 回复于:2004-11-07 16:10:39 |
是啊
能说明白一点吗? 看不明白 |
phoenixup 回复于:2004-11-17 09:38:49 |
真的相当不错,安装成功,谢谢了! |
奇迹的逍遥 回复于:2004-11-17 11:29:01 |
好贴,支持,已经收藏~~ |
shitian8848 回复于:2004-11-17 22:38:25 |
不错,已经整合成功~~~
另外给一个大家使tomcat随系统一起启动的shell脚本,自己写的,仅供参考.:em02: :em02: [code:1:51a8ceefdf] #!/bin/bash # chkconfig: 2345 99 10 # description: Start or stop the Tomcat server #pidfile: /var/run/tomcat.pid . /etc/rc.d/init.d/functions RETVAL=0 prog="Tomcat" #设置环境变量 JAVA_HOME=/opt/j2sdk CLASSPATH=/opt/j2sdk/lib/tools.jar CATALINA_HOME=/opt/tomcat5 PID_FILE=/var/run/tomcat.pid PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:$JAVA_HOME/bin:$CATALINA_HOME/bin export JAVA_HOME CLASSPATH CATALINA_HOME PATH start(){ echo -n "Starting $prog:" startup.sh >/dev/null RETVAL=$? [ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat [ $RETVAL = 0 ] && echo_success || echo_failure result=`ps -aux|grep java|awk -F " " '{if ($11!~/grep/) print $2}'` if [ ! -z $PID_FILE ] ; then echo $result > $PID_FILE fi echo return $RETVAL } stop(){ echo -n "Stopping $prog:" kill -9 `cat $PID_FILE` RETVAL=$? [ $RETVAL = 0 ] && rm /var/lock/subsys/tomcat [ $RETVAL = 0 ] && echo_success || echo_failure if [ ! -z $PID_FILE ] ; then rm -rf $PID_FILE fi echo return $RETVAL } status(){ result=`ps -aux|grep java|awk -F " " '{if ($11!~/grep/) print $2}'` if [ $result ] ; then echo "$prog (pid $result) 正在运行" else echo "$prog 已停" fi } case "$1" in start) start ;; stop) stop ;; status) status ;; restart|reload) stop start ;; *) echo "Usage:$0 {start|stop|status|restart|reload}" RETVAL=1 esac exit $RETVAL [/code:1:51a8ceefdf] 把上面的代码保存为tomcat,修改一下相关的变量,然后cp到/etc/rc.d/init.d/下 然后执行chkconfig --add tomcat。 |
guyl 回复于:2004-11-26 18:56:02 |
太好了,我还没试,回头就安装,就凭提供者的认真劲,先感谢一下下 |
ldiqing 回复于:2004-12-30 00:21:04 |
确实是好文章,谢谢楼主! |
sleepcat 回复于:2005-01-24 19:01:54 |
安装之后测试页正常显示,可是加上站点时有如下错误:
type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: -1 in the jsp file: null Generated servlet error: [javac] Compiling 1 source file /usr/local/jakarta-tomcat-5.0.18/work/Catalina/localhost/_/org/apache/jsp/bbs/errorPage_jsp.java:8: package .net.lybbs.forum does not exist import net.lybbs.forum.*; ^ /usr/local/jakarta-tomcat-5.0.18/work/Catalina/localhost/_/org/apache/jsp/bbs/errorPage_jsp.java:9: package net.lybbs.util does not exist import net.lybbs.util.*; ^ 2 errors org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351) org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415) org.apache.jasper.compiler.Compiler.compile(Compiler.java:458) org.apache.jasper.compiler.Compiler.compile(Compiler.java:439) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) note The full stack trace of the root cause is available in the Tomcat logs. 帮忙给看一下。 |
ngcode 回复于:2005-02-08 22:47:08 |
你好,我的出来的也是源代码(rh9、apache2、tomcat5)。能用rh DS3的mod_jk2吗?请发一个mod_jk2到这个邮箱:ngcode@126.com,谢谢! |
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/