Linux + Apache + Tomcat + Connector

来源:互联网 发布:知乎 保密协议 编辑:程序博客网 时间:2024/04/28 16:31

说明: 

本文是备份一下Apachetomcat的编译配置,不准备说明ajp12 或者ajp13的区别,也不准备说明Apache/Tomcatload balancer,更不准备说明如何将一个web app静态和动态的页面分开,提高系统的处理性能,具体的关注点请参考网上相关文章。

 

准备:

1. 安装了Linux的服务器/PC也可以,以RHEL5为例

2.Tomcat 6

3.Apache 2.2 Src (wget http://www.apache.org/dist/httpd/httpd-2.2.17.tar.gz)

4.Tomcat 6 (wget http://www.apache.org/dist/tomcat/tomcat-6/v6.0.30/bin/apache-tomcat-6.0.30.tar.gz)

5. Tomcat connector(wget http://mirror.bjtu.edu.cn/apache//tomcat/tomcat-connectors/jk/source/jk-1.2.31/tomcat-connectors-1.2.31-src.tar.gz)

 

开始安装

1. Apache

a. tar zxvf httpd-2.2.17.tar.gz

b. cd httpd-2.2.17

c. ./configure --prefix=/opt/httpd --enable-so

d. make

e. make install

f. Change ServerName to your IP address.

g. /opt/httpd/bin/apachectl start --> make sure can see "It works" from the browser.(port 80)

2. tomcat 

tar xzxf apache-tomcat-6.0.30.tar.gz -C /opt/tomcat6

/opt/tomcat6/bin/startup.sh--> make sure can see default pages (port 8080)

3. Compile connector

a. tar zxvf tomcat-connectors-1.2.31-src.tar.gz

b. cd tomcat-connectors-1.2.31/native

c. ./configure --with-apxs=/opt/httpd/bin/apxs

d. make

e. cp apache2/mod_jk.so /opt/httpd/modules/

 

4. configure apache

a. cd /opt/httpd/conf

b. nano httpd.conf, add following configuration to the end of the config file:

 

LoadModule jk_module modules/mod_jk.so

JkWorkersFile conf/workers.properties

JkMountFile conf/uriworkermap.properties

JkLogFile /opt/httpd/logs/jk_mod.log

JkLogLevel infoJkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

c. create workers.properties under DIR conf

worker.list= myworker

worker. myworker.type=ajp13

worker. myworker.host=localhost

worker. myworker.port=8009

worker. myworker.mount=/*

d. create uriworkermap.properties under DIR conf

/=myworker

/*=myworker

 

5. disable other service port except 8009/8443 for tomcat6 (optional)

edit /opt/tomcat6/conf/server.xml

 

6. Test. request from the Web browser, can see jsp pages from port 80(apache default service port).

 

7. Good Luck.

 



原创粉丝点击