MyException - 我的异常网
当前位置:我的异常网» Apache » 配备Apache+tomcat

配备Apache+tomcat

www.MyException.Cn  网友分享于:2013-03-15  浏览:2次
配置Apache+tomcat

(一) 修改 /etc/httpd/conf.d/vhost.conf 这个是apache的重要配置文件。截图如下

#<VirtualHost *:80>
#        ServerName test.genomics.cn
#        DocumentRoot "/website/webApplications/Events"
#        DirectoryIndex index.jsp
#        JkMount /* work1
#        JkMount /*.do work1
#        JkUnMount /uploadfile/*   work1
#        ErrorLog logs/events-error_log
#        CustomLog logs/events-access_log common
#</VirtualHost>
<VirtualHost *:80>
        ServerName test.genomics.cn
        DocumentRoot "/website/webApplications/BGI"
        DirectoryIndex index.jsp
        JkMount /* work3
        JkMount /*.do work3
        ErrorLog logs/events-error_log
        CustomLog logs/events-access_log common
</VirtualHost>
Listen 9527
<VirtualHost *:9527>
        ServerName test.genomics.cn
        DocumentRoot "/website/webApplications/HIMS_Customer/customer"
        DirectoryIndex index.jsp
        JkMount /* work3
        JkMount /*.do work3
        ErrorLog logs/customer-error_log
        CustomLog logs/customer-access_log common
</VirtualHost>
<VirtualHost *:80>
        ServerName 192.168.224.85
        DocumentRoot "/website/webApplications/GeneBookHttps"
        <Directory /website/webApplications/GeneBookHttps>
           Order allow,deny
           Allow from all
        </Directory>
        DirectoryIndex index.jsp
        JkMount /* work5
        JkMount /*.do work5
        ErrorLog logs/GenebookHttps-error_log
        CustomLog logs/GenebookHttps-access_log common
</VirtualHost>

 

   这里可以配置多个监听80端口的项目,以最后一个为准。

 

(二)

配置 apache 跟 tomcat 的交互转发

vim   /etc/httpd/conf/workers.properties


# Defining a worker named worker1 and of type ajp13
ps=/
worker.list=work1,work2,work3,work4
# Set properties for TEST
worker.work1.type=ajp13
worker.work1.host=localhost
worker.work1.port=8009
worker.work1.lbfactor=1
#Set properties for BGI
worker.work2.type=ajp13
worker.work2.host=localhost
worker.work2.port=8010
worker.work2.lbfactor=1
#Set for customer
worker.work3.type=ajp13
worker.work3.host=localhost
worker.work3.port=8116
worker.work3.lbfactor=1
#Set for PgappWeb
worker.work4.type=ajp13
worker.work4.host=localhost
worker.work4.port=8011
worker.work4.lbfactor=1

#Set for GenebookHttps
worker.work5.type=ajp13
worker.work5.host=localhost
worker.work5.port=8060
worker.work5.lbfactor=1
可以配置转发多个 ajp13(apache跟tomcat通信的协议)协议的端口也就是多个  tomcat服务

 

(三)上面 8060端口配置必须和Tomcat 的 ajp1.3协议对应的端口一致

  vim $tomcat_home/conf/server.xml

 

 <!-- Define an AJP 1.3 Connector on port 8009 -->
  <Connector port="8060" protocol="AJP/1.3" redirectPort="8443" />
 这就是 Apache跟 tomcat通信(使用AJP/1.3协议)使用的自定义端口,也是平时开发中很少用到的端口。

其他两个端口分别是关闭的 shutdown端口,和Http协议端口。还有一个用的比较少的是Https的端口。

 

这样配置之后,可以直接地址栏输入ip地址,即可访问work5对应的项目。

附:机器配置

[**@template icon]$ uname -a
Linux template 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

 

 [**@template icon]$ cat /proc/version
Linux version 2.6.18-194.el5 (mockbuild@x86-005.build.bos.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Tue Mar 16 21:52:39 EDT 2010

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有