---
title: "普通用户下实现Apache 2.2.14与jboss-5.1.0.GA集成"
author: "ginge"
date: "2009-11-29T23:05:03Z"
tags: []
categories: ["编程语言"]
slug: "apache-2-2-14-jboss-5-1-0-ga"
draft: false
lastmod: "2009-11-29T23:05:03Z"
id: 534256
url: "https://ginge.iteye.com/blog/534256"
---

Apache与jboss集成，实际是apache与tomcat的集成，有两种方式。一种是长久以来

大多数网站包括**阿**里**巴巴**都是采用的mod\_jk。还有一种就是反向代理。反向代理是2004年之后才出现的，因为相对比较新，而商业应用对于环境很很谨慎，所以目前以mod\_jk集成为多。

 

**下载Apache：**

http://apache.etoak.com/httpd/httpd-2.2.14.tar.gz

 

**安装步骤：**

\[Ginge@localhost servers]$./configure –prefix=/home/Ginge/servers/apache --with-ldap --enable-mods-shared="all ssl ldap cache proxy authn\_alias mem\_cache file\_cache authnz\_ldap charset\_lite dav\_lock disk\_cache"

\[Ginge@localhost servers]$make

\[Ginge@localhost servers]$make install

 

**说明：**

--prefix                  指apache最终安装目录

--enable-mods-shared      定义编译为动态加载的模块名单，这些模块必须以LoadModule指令加载，当然也可以--enable-mods-shared=most或者--enable-mods-shared=all。只是--enable-mods-shared=most 和--enable-mods-shared=all不会编译和生成所有模块。需要这么做就一定要使用：--with-ldap --enable-mods-shared="all ssl ldap cache proxy authn\_alias mem\_cache file\_cache authnz\_ldap charset\_lite dav\_lock disk\_cache"

 

**官方Configure手册：**

http://httpd.apache.org/docs/2.2/programs/configure.html#installationdirectories

 

 

一般来说，人们都是用root帐户来运行apache的，因此这个时候很多事情都不用做了，只需要运行httpd –k start就好了。可是如果想在最大化的利用硬件资源在一个主机上运行多个实例的apache要做些什么事情呢？

1）  首先是要修改监听端口，只有root用户才可以绑定到80端口上。在本次安装就让apache监听到了10080端口

2）  运行apache的用户不可以是默认的daemon，因为普通用户根本就没有权限切换到其他用户去，所以要修改httpd.conf中的user daemon, group daemon为当前用户

 

**下载tomcat-connector：**

http://apache.freelamp.com/tomcat/tomcat-connectors/jk/source/jk-1.2.28/tomcat-connectors-1.2.28-src.tar.gz

 

\[Ginge@localhost servers]$tar tomcat-connectors-1.2.28-src.tar.gz

\[Ginge@localhost servers]$cd tomcat-connectors-1.2.28-src

\[Ginge@localhost servers]$cd native

\[Ginge@localhost servers]$./configure --with-apxs=/home/Ginge/servers/apache/bin/apxs

\[Ginge@localhost servers]$cp apache-2.0/mod\_jk.so /home/Ginge/servers/apache/modules/

 

 

要使apache知道有mod\_jk转发，就要定义mod\_conf配置以及在httpd.conf中加载

Include conf/mod\_jk.conf。

\[Ginge@localhost servers]$vi mod\_jk.conf

LoadModule jk\_module modules/mod\_jk.so

JkMount /web-console/* localnode

JkWorkerProperty worker.list=localnode

JkWorkerProperty worker.localnode.port=8090

JkWorkerProperty worker.localnode.host=localhost

JkWorkerProperty worker.localnode.type=ajp13

 

以下按照实际情况来配置，xxx都为数字：

JkWorkerProperty worker.localnode.lbfactor=xxx

JkWorkerProperty worker.localnode.socket\_keepalive=True

JkWorkerProperty worker.localnode.socket\_timeout=xxx

JkWorkerProperty worker.localnode.connection\_pool\_minsize=xxx

JkWorkerProperty worker.localnode.connection\_pool\_timeout=xxx

 

**Jboss只要到jboss去下载，解压即可使用，修改jboss配置：**

\[Ginge@localhost servers]$vi ./server/default/deploy/jbossweb.sar/server.xml

找到&lt;Engine name="jboss.web" defaultHost="localhot"&gt;元素，添加jvmRoute属性，

&lt;Engine name="jboss.web" defaultHost="localhot" jvmRoute="localnode"&gt;。

 

最后来验证一下是否集成成功，在浏览器敲入

[http://192.168.0.81:10080/web-console/](http://192.168.0.81:10080/web-console/)![](http://dl.iteye.com/upload/attachment/174161/0f97be0f-55b8-3450-a63d-43aaee4bdfc4.jpg)