|
经过多次测试,基本没有问题。
安装过程中需要注意有几个目录和文件需要自己建立,上面文档中省略了。
记得最后要重起Apace和Tomcat,否则会出现500错误。
实验环境:Linux 2.6.9-5.EL
所需要的文件
# ls
httpd-2.0.54.tar.gz
jakarta-tomcat-connectors-jk2-src-current.tar.gz
jdk-1_5_0_03-linux-i586.bin
jakarta-tomcat-5.5.9.tar.gz
libtool-1.5.8.tar.gz
apr-1.1.1.tar.gz
apr-util-1.1.2.tar.gz
1.安装JDK
解压缩 jdk-1_5_0_03-linux-i586.bin
# ./jdk-1_5_0_03-linux-i586.bin
翻页,提示后输入y
移动jdk1.5.0_03到/usr/local/下
# mv jdk1.5.0_03 /usr/local/
建立/usr/local/下的jdk连接
# ln -s /usr/local/jdk1.5.0_03 /usr/local/jdk
设置环境变量
# vi /etc/profile
在最后加入:
[code:1]
JAVA_HOME=/usr/local/jdk
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=$JAVA_HOME/lib/tools.jar
export JAVA_HOME CLASSPATH
[/code:1]
# wq
查看java环境变量
# source /etc/profile
# java -version
提示如下证明设置正确
[code:1]
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)
[/code:1]
2.安装Tomcat-5.5.9
解压缩 jakarta-tomcat-5.5.9.tar.gz
# tar zxvf jakarta-tomcat-5.5.9.tar.gz
将 jakarta-tomcat-5.5.9.tar.gz安装在/usr/local/目录下
# mv jakarta-tomcat-5.5.9 /usr/local/
启动TOMCAT
# /usr/local/jakarta-tomcat-5.5.9/bin/startup.sh
[code:1]
Using CATALINA_BASE: /usr/local/jakarta-tomcat-5.5.9
Using CATALINA_HOME: /usr/local/jakarta-tomcat-5.5.9
Using CATALINA_TMPDIR: /usr/local/jakarta-tomcat-5.5.9/temp
Using JRE_HOME: /usr/local/jdk1.5.0_03
[/code:1]
建立jakarta-tomcat-5.5.9到tomcat软连接
# ln -s jakarta-tomcat-5.5.9 tomcat
查看TOMCAT是否正常运行
http://192.168.0.157:8080
如果能打开说明TOCAT已经正常运行了
3.安装apache
# cd ..
# tar zxvf httpd-2.0.54.tar.gz
# cd httpd-2.0.54
# ./configure --prefix=/usr/local/httpd2 --enable-module=most --enable-shared=max
# make
# make install
察看编译进apache的模块:
# /usr/local/httpd2/bin/httpd -l
[code:1]
Compiled in modules:
core.c
mod_access.c
mod_auth.c
mod_include.c
mod_log_config.c
mod_env.c
mod_setenvif.c
prefork.c
http_core.c
mod_mime.c
mod_status.c
mod_autoindex.c
mod_asis.c
mod_cgi.c
mod_negotiation.c
mod_dir.c
mod_imap.c
mod_actions.c
mod_userdir.c
mod_alias.c
mod_so.c
[/code:1]
看到以上的信息表明apache支持dso方式了。
这样就可以用dso的方式把php和tomcat-connectors的模块加进来。
4.安装jakarta-tomcat
tomcat-connectors 用来整合apache和tomcat,编译生成mod_jk2.so模块,apache加载之后,就能将不属
于自己的请求转发给tomcat。
回到原目录,解压缩
# tar zxfz jakarta-tomcat-connectors-jk2-src-current.tar.gz
# cd jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2
配置编译
# ./configure --with-apxs2=/usr/local/httpd2/bin/apxs
编译过程中提示:configure: error: can't locate libapr
到http://apache.osuosl.org/apr/下载libapr和libaprutil
# cd ../..
下载apr-1.1.1.tar.gz和apr-util-1.1.2.tar.gz
# wget http://apache.osuosl.org/apr/apr-1.1.1.tar.gz
# wget http://apache.osuosl.org/apr/apr-util-1.1.2.tar.gz
解压缩安装libapr
# tar zxvf apr-1.1.1.tar.gz
# cd apr-1.1.1
# ./configure
# make
# make install
# cd ..
解压缩安装libaprutil
# tar zxvf apr-util-1.1.2.tar.gz
# cd apr-util-1.1.2
# ./configure --with-apr=../apr-1.1.1
# make
# make install
建立libapr和libaprutil 的软连接到/usr/local/httpd2/lib/目录下
# ln -s /usr/local/apr/lib/libapr-1.so.0.1.1 /usr/local/httpd2/lib/libapr-1.so
# ln -s /usr/local/apr/lib/libapr-1.so.0.1.1 /usr/local/httpd2/lib/libapr-1.so.0
# ln -s /usr/local/apr/lib/libaprutil-1.so.0.1.1 /usr/local/httpd2/lib/libaprutil-1.so
# ln -s /usr/local/apr/lib/libaprutil-1.so.0.1.1 /usr/local/httpd2/lib/libaprutil-1.so.0
# rpm -e libtool
下载libtool-1.5.8.tar.gz
# wget http://ftp.gnu.org/gnu/libtool/libtool-1.5.8.tar.gz
解压缩安装
# tar zxvf libtool-1.5.8.tar.gz
# cd libtool-1.5.8
# ./configure
# make
# make install
删除原来的/usr/local/httpd2/build/libtool
# rm –rf /usr/local/httpd2/build/libtool
建立新的libtool 软连接
# ln -s /usr/local/bin/libtool /usr/local/httpd2/build/libtool
回到原目录下,再次编译jakarta-tomcat-connectors
# rm -rf jakarta-tomcat-connectors-jk2-2.0.4-src
# tar vxfz jakarta-tomcat-connectors-jk2-src-current.tar.gz
# cd jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2
配置编译
# ./configure --with-apxs2=/usr/local/httpd2/bin/apxs
# make
# cd ../build/jk2/apache2/
拷贝mod_jk2.so到/usr/local/apache2/modules目录下。
# cp mod_jk2.so /usr/local/httpd2/modules/
5.配置
# vi /usr/local/httpd2/conf/httpd.conf
请参照下文进行修改
[code:1]
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>
JkSet config.file /usr/local/httpd2/conf/workers2.properties
[/code:1]
创建/usr/local/httpd2/conf/workers2.properties,内容如下:
[code:1]
[logger]
level=ERROR
[config:]
file=/usr/local/httpd2/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
[/code:1]
修改/usr/local/tomcat/conf/server.xml
在
[code:1]
<Host name="localhost" debug="0" appBase="apps"
unpackWARs="true" autoDeploy="true">
[/code:1]
段中添加:
[code:1]
<Context path="" docBase="/var/www/html" debug="0"
reloadable="true" crossContext="true"/>
[/code:1]
保存退出。
7.测试:
在/var/www/html/下创建test.jsp,
内容:
[code:1]
<%@ page import="java.util.*,java.sql.*,java.text.*" contentType="text/html;charset=gb2312"
%>
<%
out.println("test page");
%>
[/code:1]
Apache和Tomcat的启动和关闭
# /usr/local/httpd2/bin/apachectl start 启动
# /usr/local/httpd2/bin/apachectl restart 重启
# /usr/local/httpd2/bin/apachectl stop 关闭
# /usr/local/tomcat/bin/startup.sh 启动
# /usr/local/tomcat/bin/shutdown.sh 关闭
如果要在计算机启动的时候就运行httpd服务,可以在/etc/rc.d/rc.local文件中加入这几行:
[code:1]
# start apache
/usr/local/httpd2/bin/apachectl start
# start tomcat
/usr/local/tomcat/bin/startup.sh
[/code:1]
访问 http://192.168.0.157/test.jsp
在实验和撰写本文过程中,参考了很多大牛们的文章,这里一并表示感谢.文中难免有谬误疏漏之处,还望批评指正.
langyufeng
引用通告地址 (0):
http://www.xjtusky.com//trackback.asp?tbID=29
http://www.xjtusky.com//trackback.asp?tbID=29&CP=GBK |
|