您的位置:首页 > 运维架构 > Tomcat

apache整合tomcat后根据不同域名访问

2014-10-08 16:14 375 查看

apache整合tomcat步骤

一、软件环境

1、系统:Ubuntu9

2、Apache:httpd-2.4.10(下载地址:http://httpd.apache.org/download.cgi)

3、依赖包:

apr-util-1.5.4、apr-1.5.1(下载地址:http://apr.apache.org/download.cgi)

pcre-8.34(下载地址:http://www.pcre.org)

假设所需软件包放于:/work/tool

二、安装过程

1、安装apr

#cd/work/tools/

#tar -jxvf apr-1.5.1.tar.bz2

#cdapr-1.5.1

#./configure

#make

#make install

2、安装apr-util

#cd/work/tools/

#tar -jxvf apr-util-1.5.4.tar.bz2

#cdapr-util-1.5.4

#./configure --prefix=/usr/local/apr -util--with-apr=/usr/local/apr

#make

#make install

3、安装pcre

#cd/work/tools/

#tar -jxvf pcre-8.34.tar.bz2

#cdpcre-8.34

#./configure --prefix=/usr/local/pcre

#make

#makeinstall

4、安装apache

./configure

--prefix=/opt/soft/local/httpd/

--with-apr=/usr/local/apr/

--with-apr-util=/opt/soft/local/apr-util/bin/apu-1-config --with-pcre=/opt/soft/local/pcre/bin/pcre-config

./configure --with-apxs=/opt/soft/local/httpd/bin/aspx

make

make install

5.安装JK

下载tomcat-connectors-1.2.40-src

在tomcat-connectors-1.2.40-src/native/apache-2.0中运行

./configure --with-apxs=/opt/soft/local/httpd/bin/aspx

make

make install

安装后设置httpd.conf

LoadModule jk_module modules/mod_jk.so

Include /opt/soft/local/httpd/conf/mod_jk.conf

mod_jk.conf文件内容如下:

JkWorkersFile /opt/soft/local/httpd/conf/workers.properties

#如果apache中将tomcat单独配置成一个虚拟主机则不用在配置uriworkermap

#JkMountFile conf/uriworkermap.properties

# Where to put jk logs

JkLogFile /opt/soft/local/httpd/logs/mod_jk.log

# Set the jk log level [debug/error/info]

JkLogLevel info

# Select the log format

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

# JkOptions indicate to send SSL KEY SIZE,

JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

# JkRequestLogFormat set the request format

JkRequestLogFormat "%w %V %T"

# 将所有servlet 和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理

# 推荐采用uriworkermap处理

#JkMount /servlet/* worker1

#JkMount /*.jsp worker1

workers.properties文件内容

# Defining a worker named worker1 and of type ajp13

worker.list=worker1

# Set properties for worker1

worker.worker1.type=ajp13

worker.worker1.host=127.0.0.1

worker.worker1.port=8009

worker.worker1.lbfactor=1

uriworkermap.properties文件内容

#二级目录为tomcat请求的都由worker1这个server处理

/tomcat/*=worker1

不采用uriworkermap.properties,直接配置httpd.conf的虚拟主机

<VirtualHost 192.168.77.247:80>

ServerName tomcat.247.com

JkMount /* worker1

</VirtualHost>

6.几条命令

chkconfig --list httpd //查看httpd服务是否已存在

/work/apache/bin/apachectl start|restart|stop //linux启动apache命令

/tomcat/bin/startup.sh //启动tomcat

netstat-an | grep :80 //查看linux80端口是否开启
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: