2008-04-08

CentOS 5.0环境下配置apache+tomcat

关键字: centos5 apache tomcat 整合
1.apache (使用CentOS自带的apache,/etc/httpd)

当然也可以自己安装一个,下载apache,然后解压缩
首先要先安装APR
cd srclib/apr
#./configure --prefix=/usr/local/apr
#make
#make install

安装APR-util
cd srclib/apr-util
#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
#make
#make install

cd apache目录
# ./configure --prefix=/usr/local/apache
--enable-so --enable-mods-shared=all
--enable-cgi
--with-apr=/usr/local/apr
--with-apr-util=/usr/local/apr-util/bin
#make
#make install
这里可以把所有模块都编译了,省得后面麻烦,然后在http.conf再把不需要的模块注释掉!

2.jre

下载jre-1_5_0-linux-i586.bin
#chmod a+x jre-1_5_0-linux-i586.bin
#vi /etc/profile

在最后加入以下语句
export JAVA_HOME=/usr/local/jdk
export CLASSPATH=$JAVA_HOME/lib

3.tomcat

解压缩,直接运行,访问http://localhost:8080 ,应该可以看到小猫!

4.整合tomcat和apache

整合的工具mod_jk,去tomcat网站下载connector包

解压缩,进入native,编译成功后记得copy到apache的modules里面
#./configure --with-apxs=/usr/sbin/apxs
#make
#cp apache-2.0/mod_jk.so /etc/httpd/modules/

注:如果是用CentOS自带的apache,需要安装#yum install httpd-devel

修改http.conf:
vi /etc/httpd/conf/httpd.conf
把NameVirtualHost *:80前面注释去掉,在结尾加上:

<VirtualHost *:80>
ServerName examples.andy.com
RewriteEngine On
RewriteRule ^\/$ http://examples.andy.com/examples [R,L]
JkMount /* examples
</VirtualHost>

然后#vi /etc/httpd/conf.d/jk.conf
添写如下内容
LoadModule jk_module modules/mod_jk.so

JkLogFile /var/log/httpd/mod_jk.log
JkLogLevel info

JkWorkerProperty worker.list=examples
JkWorkerProperty worker.examples.type=ajp13
JkWorkerProperty worker.examples.host=localhost
JkWorkerProperty worker.examples.port=8009
JkWorkerProperty worker.examples.connection_pool_timeout=600
JkWorkerProperty worker.examples.socket_keepalive=True
JkWorkerProperty worker.examples.socket_timeout=60

记住如果有多个虚拟主机,就把每个[JkMount /* 别名]这里的别名在jk.conf里面定义多个就可以了!

直接启动apache,tomcat,输入http://examples.andy.com 是不是会跳转到tomcat的例子程序上去了呢!^ ^ 别忘了修改你的hosts文件哦!
评论
发表评论

您还没有登录,请登录后发表评论

kj2ff
搜索本博客
我的相册
39723bb3-0a9b-3357-b6b8-b9ae94144985-thumb
001
共 3 张
最近加入圈子
存档
最新评论