- 论坛徽章:
- 0
|
freebsd4.8环境下apache2.0.47与tomcat5.0.19整合配置笔记(对linux环境的补充)
oldboy 2004.3.1 From:bbs.youhow.net
写这篇文章的目的:
搜遍CU发现关于apache和tomcat整合的文章都是linux环境下的,而在freebsd环境用同样的方法编译存在很多问题,所以把我在配置过程中遇到的问题和解决方法和大家分享一下:
首先安装JDK
shell#tar zxvf jdk1.4.1-freebsd48.tar.gz -C /usr/local
shell#ln -s /usr/local/jdk1.4.1/ /usr/local/jdk
设置环境变量和路径
setenv JAVA_HOME /usr/local/jdk
setenv CLASSPATH $JAVA_HOME/lib
set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin /usr/X11R6/bin /usr/local/bin $HOME/bin $JAVA_HOME/bin)
编译安装apache
shell#tar zxvf httpd-2.0.47.tar.gz
shell#cd httpd-2.0.47
shell#./configure --prefix=/usr/local/apache --enable-module=so
shell#make
shell#make install
安装tomcat
shell#tar zxvf jakarta-tomcat-5.0.19.tar.gz -C /usr/local/
shell#ln -s /usr/local/jakarta-tomcat-5.0.19/ /usr/local/tomcat
shell#vi /usr/local/tomcat/conf/jk2.properties
## THIS FILE MAY BE OVERRIDEN AT RUNTIME. MAKE SURE TOMCAT IS STOPED
## WHEN YOU EDIT THE FILE.
## COMMENTS WILL BE _LOST_
## DOCUMENTATION OF THE FORMAT IN JkMain javadoc.
# Set the desired handler list
handler.list=channelSocket,request
#
# Override the default port for the socketChannel
channelSocket.port=8009
# Default:
# channelUnix.file=${jkHome}/work/jk2.socket
# Just to check if the the config is working
# shm.file=${jkHome}/work/jk2.shm
# In order to enable jni use any channelJni directive
# channelJni.disabled = 0
# And one of the following directives:
# apr.jniModeSo=/opt/apache2/modules/mod_jk2.so
# If set to inprocess the mod_jk2 will Register natives itself
# This will enable the starting of the Tomcat from mod_jk2
# apr.jniModeSo=inprocess
编译jk2前,需要安装gmake、autoconf和automake
shell#cd /usr/ports/devel/gmake
shell#make install
shell#cd /usr/ports/devel/autoconf
shell#make install
shell#cd /usr/ports/devel/automake
shell#make install
编译安装jk2(在这里我发现无法编译通过,经过研究发现编译时需要使用gmake,并且需要对编译配置文件进行修改)
shell#tar zxvf jakarta-tomcat-connectors-jk2-src-current.tar.gz
shell#cd jakarta-tomcat-connectors-jk2-2.0.2-src/
shell#cd jk/native2
shell#chmod 755 buildconf.sh
shell#./buildconf.sh
shell#vi configure
查找
# Actually configure libtool. ac_aux_dir is where install-sh is found.
CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
|| { { echo "$as_me LINENO: error: libtool configure failed" >;&5
echo "$as_me: error: libtool configure failed" >;&2;}
{ (exit 1); exit 1; }; }
更改为
#CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
#LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
#LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
#DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
#${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
#$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
#|| { { echo "$as_me LINENO: error: libtool configure failed" >;&5
#echo "$as_me: error: libtool configure failed" >;&2;}
# { (exit 1); exit 1; }; }
shell#./configure --with-apxs2=/usr/local/apache/bin/apxs --enable-EAPI
shell#vi server/apache2/Makefile
查找
EXTRA_CPPFLAGS=-D_REENTRANT -D_THREAD_SAFE
更改为
EXTRA_CPPFLAGS=
查找
LIBTOOL=${APACHE2_HOME}/build/libtool
更改为(视自己系统的具体信息来定)
LIBTOOL=/usr/local/bin/libtool
把编译好的模块文件copy到apache的modules目录中
shell#cd ../build/jk2/apache2/
shell#cp mod_jk2.so /usr/local/apache/modules/
编辑apache配置文件
shell#vi /usr/local/apache/conf/workers2.properties
# only at beginnin. In production uncomment it out
[logger.apache2]
level=DEBUG
[shm]
file=/usr/local/apache/logs/shm.file
size=1048576
# Example socket channel, override port and host.
[channel.socket]
port=8009
host=127.0.0.1
# define the worker
[ajp13]
channel=channel.socket:localhost:8009
# Uri mapping
[uri:192.168.0.90/*.jsp]
worker=ajp13:localhost:8009
shell#vi /usr/local/apache/conf/http.conf
#添加index.jsp
DirectoryIndex index.html index.html.var index.jsp
LoadModule jk2_module modules/mod_jk2.so
<Directory ~ "\CVS" >;
Order deny,allow
Deny from all
</Directory>;
<Location /WEB-INF/>;
Order Allow,Deny
</Location>;
<VirtualHost 202.108.59.54>;
ServerName tomcat.boosen.com
ServerAdmin webmater@boosen.com
DocumentRoot /usr/local/tomcat/webapps
ErrorLog /usr/local/apache/logs/boosen.com-errorlog
CustomLog /usr/local/apache/logs/boosen.com-access.log common
<Location "/*.jsp">;
JkUriSet worker ajp13:localhost:8009
</Location>;
</VirtualHost>;
启动tomcat和apache
shell#/usr/local/tomcat/bin/startup.sh
shell#/usr/local/apache/bin/apachectl start
希望能对大家有所帮助! |
|