当前位置:首页 > 服务器技术 > apache

apache2.2用proxy_ajp方式整合tomcat6.0

<spanComic Sans MS'; font-size:24px; line-height:26px; text-align:right">Apache2.2用proxy ajp方式整合Tomcat6.0

小狼@http://blog.csdn.net/xiaolangyangyang

google一下这样的文章还真不少.但一些不太全也不太适合我.只好自己写了

本文主要用httpd2.2的porxy_ajp来连接tomcat

我的环境为:Centos5.2

下载最新版本的apache目前最新版本为httpd-2.2.10.tar.gz

下载最新版本的tomcat日前最新版本为apache-tomcat-6.0.18.tar.gz

jdk1.6

在http://apr.apache.org下载最新的apr-1.3.3和apr-util-1.3.4

一、开始安装

1. #编译apr

<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">#tar <spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">zxvf apr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">1<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">3<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">3<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">tar<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">gz

<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">#cd apr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">1<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">3<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">3

<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">#.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">configure<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">prefix<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">=<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">usr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">local<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">apr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">httpd<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/

<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">#make

<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">#make install

2. #编译apr-util

<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">#tar <spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">zxvf apr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">util<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">1<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">3<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">4<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">tar<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">gz<brCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">#cd apr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">util<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">1<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">3<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">4<brCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">#.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">configure<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">prefix<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">=<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">usr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">local<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">apr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">util<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">httpd<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">with<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">apr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">=<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">usr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">local<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">apr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">httpd<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<brCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">#make<brCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">#make install

3. #编译httpd

<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">#tar<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">zxvf httpd<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">2<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">2<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">10<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">tar<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">gz<brCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">#cd httpd<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">2<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">2<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">10<brCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">#.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">configure<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">prefix<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">=<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">usr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">local<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">apache2<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">with<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">apr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">=<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">usr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">local<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">apr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">httpd<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">with<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">apr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">util<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">=<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">usr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">local<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">apr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">util<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">httpd<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">enable<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">so<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">enable<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">mods<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">shared<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">=<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">most<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<brCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">enable<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">rewrite<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">=<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">shared<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">enable<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">proxy<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">=<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">shared<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">enable<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">proxy<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">ajp<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">=<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">shared<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">enable<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">proxy<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">balancer<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">=<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">shared<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">enable<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">speling<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">=<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">shared<brCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">#make<brCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">#make install

启动:

<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">#/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">usr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">local<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">apache2<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">bin<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">apachectl start

测试是否安装正确 用这个http://yourip/显示apache默认页面为It works!

4. 配置tomcat

1) #安装JDK1.6

在java.sun.com下载jdk后直接安装就可以

2) #设置环境变量

vim /etc/profile 添加:

export JAVA_HOME=/usr/java/jdk
export JRE_HOME=$JAVA_HOME/jre
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

3) #安装tomcat

<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">#tar<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">zxvf apache<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">tomcat<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">6<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">0<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">18<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">tar<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">gz<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">C<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">usr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">local<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<brCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">#mv<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">usr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">local<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">apache<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">tomcat<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">-<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">6<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">0<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">18 tomcat

4) 启动tomcat并测试

<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)"><spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">#/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">usr<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">local<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">tomcat<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">bin<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">/<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">startup<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre; color:rgb(0,0,204)">.<spanCourier New',Courier,monospace; font-size:14px; line-height:21px; white-space:pre">sh

5) 访问:http://yourip:8080/如果看到默认首页证明安装成功

二.整合apache和tomcat

我这里的apache的根目录和tomcat的根目录不在同一目录,当然了你完全可以放在同一目录下

我的apache的根目录在/www tomcat的根目录在/usr/local/tomcat/webapps

修改apache的httpd.conf

添加模块:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

打开Virtual hosts 即去掉Include conf/extra/httpd-vhosts.conf一行的注释

注释掉DocumentRoot和ServerAdmin

编辑httpd-vhosts.conf

添加:

<VirtualHost*:80>
    ServerAdmin jsjzhang@gmail.com
    DocumentRoot "/www/web"         #此虚拟主机的主目录为/www/web
   <Directory "/www/web">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    

    ServerName www.terr.com         #只是测试,生产环境可以写为对应的域名
    ProxyPass /images !             #以下几行的意思是对/images,/sna  和/news/images几个目录的访问请求由apache处理其它都由tomcat处理.
    ProxyPass /sna !
    ProxyPass /news/images!
    ProxyPass / ajp://localhost:8009/

    ProxyPassReverse / ajp://localhost:8009/

    ErrorLog "logs/3.249-error_log"
    CustomLog "logs/3.249-access_log" common
如何有多个虚拟主机可以再添加.例如:
<VirtualHost*:80>
    ServerAdmin jsjzhang@gmail.com
    DocumentRoot "/www/web2" 
   <Directory "/www/web2">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    

    ServerName www.terr2.com            
    ProxyPass /images !             
    ProxyPass /sna !
    ProxyPass /news/images!
    ProxyPass / ajp://localhost:8009/

    ProxyPassReverse / ajp://localhost:8009/

    ErrorLog "logs/3.249-error_log"
    CustomLog "logs/3.249-access_log" common

注: 生产环境下这些虚拟主机都是用域名访问的.因为他们都对应同一个IP。如何用IP访问一般打开的为最一个虚拟主机的主页。

把web这个网站放到tomcat的主目录/usr/local/tomcat/webapps下,其中images,sna和/news/images这三个目录放到/www/web下当然了我的apache还有其它用处所以没有和tomcat设为同一主目录为了简单你当然可以这么做,但一定要记得把apache中虚拟主机中的<Directory "/www/web">修改为和你tomcat一致的主目录,例如我这里应

该设为:<Directory "/usr/local/tomcat/webapps">

三.测试

现在启动tomcat启动apache在浏览器输入http://www.terr.com/web看看效果吧,因为是测试所以我在只在hosts里面对www.terr.com做了解析。

以上就介绍了apache2.2用proxy_ajp方式整合tomcat6.0,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!