- 浏览: 26261 次
- 性别:
- 来自: 上海
文章分类
最新评论
1. 环境配置以及安装指南
Apache:httpd-2.2.21
Mod_jk: tomcat-connectors-1.2.32-src.tar.gz
Tomcat: apache-tomcat-7.0.23.tar.gz
版本说明信息; http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html
1.1 安装apache
A:解压apache
tar -zxvf httpd-2.2.21-beta.tar.gz
cd httpd-2.3.16-beta
B:配置
./configure --prefix=/ceno/product/httpd --enable-module=vhost_alias --enable-module=so
Make
Make install
C:提示缺少apr以及aprutil,pcre,则需要先编译apr,aprutil以及pcre.
C1:下载apr,aprutil 以及 pcre
apr: http://apr.apache.org/download.cgi
apr-util: http://apr.apache.org/download.cgi
pcre: http://pcre.org/、 http://sourceforge.net/projects/pcre/
c2:安装apr:
tar zxvf apr-1.4.5.tar.gz
cd apr-1.4.5
./configure --prefix=/usr/local/apr
Make
make install
c3:安装aprtuil
tar zxvf apr-util-1.3.10.tar.gz
cd apr-util-1.3.10
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
Make
make install
c4安装pcre
tar zxvf pcre-8.11.tar.gz
cd pcre-8.11
./configure --prefix=/usr/local/pcre
Make
make install
D:重新编译httpd
cd httpd-2.2.21
./configure --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --prefix=/ceno/product/httpd --enable-module=vhost_alias --enable-module=so
Make
Make install
1.2 安装并编译mod_jk
Tar –zxvf tomcat-connectors-1.2.32-src.tar.gz
Cd tomcat-connectors-1.2.32-src/native
./configure --with-apxs=/ceno/product/httpd/bin/apxs
Make
Su –c ‘make install’
1.3 解压tomcat7.0
Tar –zxvf apache-tomcat-7.0.23.tar.gz
Cd /ceno/product/
Ln –s /work/apache/ apache-tomcat-7.0.23 tomcat
2. 配置篇章
2.1 配置httpd.conf
Cd /ceno/product/httpd/conf
Vi httpd.conf
下面是
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
ServerName 192.168.7.18:80
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
#DocumentRoot "/ceno/product/httpd/htdocs"
DocumentRoot "/ceno/product/tomcat/webapps/examples"
<Directory "/ceno/product/tomcat/webapps/examples">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
#加入mod_jk配置
Include conf/jk/mod_jk.conf
2.2 在httpd/conf 下添加jk目录,配置mod_jk.conf
Cd /ceno/product/httpd/conf/jk/
#load mod_jk module
LoadModule jk_module modules/mod_jk.so
# Declare the module for <IfModule directive> (remove this line on Apache 2.0.x)
#AddModule mod_jk.c
# Where to find workers.properties
JkWorkersFile /ceno/product/httpd/conf/jk/workers.properties
# Where to put jk shared memory
JkShmFile /ceno/product/httpd/mod_jk.shm
# Where to put jk logs
JkLogFile /ceno/product/httpd/logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel debug
# Select the timestamp 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"
# Static files in all Tomcat webapp context directories are served by apache
JkAutoAlias /ceno/product/tomcat/webapps/examples
# All requests go to worker1 by default
JkMount /* balance1
# Serve html, jpg and gif using httpd
JkUnMount /*.html balance1
JkUnMount /*.jpg balance1
JkUnMount /*.gif balance1
# Add the jkstatus mount point
JkMount /jkmanager/* jkstatus
workers.properties
# the list of workers
worker.list= worker1,worker2,balance1,jkstatus
##
##worker.worker name.type=<worker type> Where worker name is the name assigned to the worker and the worker type is one of the four types defined in the table
##(a worker name may only contain any space the characters [a-zA-Z0-9\-_]).
##Type Description
#ajp12 This worker knows how to forward requests to out-of-process Tomcat workers using the ajpv12 protocol.
#ajp13 This worker knows how to forward requests to out-of-process Tomcat workers using the ajpv13 protocol.
#jni DEPRECATED: This worker knows how to forward requests to in-process Tomcat workers using JNI.
#lb This is a load-balancing worker; it knows how to provide round-robin based sticky load balancing with a certain level of fault-tolerance.
#Defines a worker named "loadbalancer" that loadbalances several Tomcat processes transparently.
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=192.168.7.18
worker.worker1.port=8009
worker.worker1.lbfactor=1
# Set properties for worker2 (ajp13)
worker.worker2.type=ajp13
worker.worker2.host=192.168.7.18
worker.worker2.port=8010
worker.worker2.lbfactor=3
#worker.worker2.connection_pool_timeout=600
#worker.worker2.socket_keepalive=1
#worker.worker2.socket_timeout=60
worker. balance1.type=lb
#
#After defining the workers you can also specify properties for them. Properties can be specified in the following manner:
#worker.<worker name>.<property>=<property value>
#
# The worker balance1 while use "real" workers worker1 and worker2
worker.balance1.balance_workers=worker1, worker2
worker.balance1.sticky_session =true
# Define a 'jkstatus' worker using status
worker.jkstatus.type=status
2.3 配置tomcat
一台机器上测试 2个tomcat:
Tomcat1:
<Server port="8005" shutdown="SHUTDOWN">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="worker1">
Tomcat2:
<Server port="8006" shutdown="SHUTDOWN">
<Connector port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8445" />
<Connector port="8010" protocol="AJP/1.3" redirectPort="8445" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="worker2">
一个tomcat 两个实例
修改/tomcat/conf/server.xml 文件,添加一个service
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">
<!-- Security listener. Documentation at /docs/config/listeners.html
<Listener className="org.apache.catalina.security.SecurityListener" />
-->
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
<Listener className="org.apache.catalina.core.JasperListener" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina1">
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR, the
connector should be using the OpenSSL style configuration
described in the APR documentation -->
<!--
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->
<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina1" defaultHost="localhost" jvmRoute="worker1">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="/ceno/product/test"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
<Service name="Catalina2">
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8444" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR, the
connector should be using the OpenSSL style configuration
described in the APR documentation -->
<!--
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8010" protocol="AJP/1.3" redirectPort="8444" />
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->
<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina2" defaultHost="localhost" jvmRoute="worker1">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="/ceno/product/test"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
2.4 配置Jk status
方法一:
在worker.peroerties 文件中增加:
worker.list=worker1,worker2,balancer1,jkstatus
# Define a 'jkstatus' worker using status
worker.jkstatus.type=status
在mod_jk.conf 中增加
# Add the jkstatus mount point
JkMount /jkmanager/* jkstatus
打开浏览器访问:
http://192.168.7.18/jkmanager
方法二:
在workers.properties 文件中添加
worker.list=worker1,worker2,balancer1,jkstatus
# Define a 'jkstatus' worker using status
worker.jkstatus.type=status
worker. jkstatus.read_only=true
worker.jkstatus.mount=/admin/status/jk
worker. jkstatus.read_only 属性 默认为false
打开浏览器访问
http://192.168.7.18/admin/status/jk
相关推荐
标题中的“httpd mod_jk.so”指的是Apache HTTP服务器(httpd)的一个模块,mod_jk.so,这个模块专门用于连接Apache与Tomcat应用服务器。Apache HTTP Server是世界上最流行的Web服务器软件之一,而Tomcat则是一个...
### mod_jk 各个版本及 Apache 与 Tomcat 的整合方法 在 IT 行业中,Apache 和 Tomcat 的整合是非常常见的需求之一。通过使用 mod_jk 这一模块,我们可以实现 Apache 和 Tomcat 之间的高效通信。mod_jk 是一个负载...
3. **配置Apache**:在Apache的配置文件(如httpd.conf)中加载`mod_jk`模块,并指定模块路径。例如,添加`LoadModule jk_module /path/to/mod_jk.so`。 4. **配置`mod_jk`**:创建一个名为`workers.properties`的...
mod_jk.so是Apache的负载均衡模块,它通过Apache与Tomcat之间的通信协议(Jk或JK2)来实现这种协同工作。 首先,我们需要理解Apache2.4和mod_jk.so的关系。Apache2.4是Apache HTTP服务器的第2.4版本,提供了许多...
此外,如果某个Tomcat实例出现故障,mod_jk还能自动将请求转发到其他健康的实例,确保服务的连续性。 在实际部署中,你需要先下载与你的Apache服务器匹配的mod_jk.so文件。根据描述,这个压缩包提供了多种版本,...
而`mod_jk.load`则在Apache的配置文件`httpd.conf`中引入,使Apache能够加载`mod_jk.so`模块。 总结一下,`mod_jk-1.2.31-httpd-2.2.3`是Apache与Tomcat集成的关键组件,用于处理动态内容请求的转发和集群管理。`...
2. **配置httpd.conf**:编辑Apache的主配置文件`httpd.conf`,添加`LoadModule`指令来加载mod_jk模块,如: ``` LoadModule jk_module modules/mod_jk.so ``` 3. **设置JKMount**:定义哪些URL由mod_jk处理。...
本篇文章将详细介绍如何在Ubuntu 10.04系统环境下,配置Apache2通过mod_jk连接到Tomcat 6.0.24。 首先,确保你已经安装了Apache2和Tomcat。在Ubuntu上,可以通过以下命令安装: ```bash sudo apt-get update sudo ...
**Windows环境下Apache HTTPD服务器与Tomcat集成使用mod_jk.so模块** Apache HTTPD服务器是广泛应用的开源Web服务器,而Tomcat则是Java Servlet和JavaServer Pages(JSP)的容器。在部署Java应用时,通常会将Apache...
3. **配置Apache**:在Apache的`httpd.conf`中配置mod_jk模块,并设置相应的SSL选项。 4. **配置Tomcat**:在Tomcat的`server.xml`中配置SSL连接器,并指定证书和私钥的位置。 5. **测试连接**:使用`Snoop.java`或...
3. **配置httpd.conf**:在Apache的配置文件`httpd.conf`中,添加`LoadModule`指令加载mod_jk模块,并配置`JkWorkersFile`和`JkMount`指令,指定worker配置文件的位置以及哪些URL应该由Tomcat处理。 4. **配置...
打开Apache的配置文件,通常是`httpd.conf`或`apache2.conf`,然后在文件末尾添加以下行来加载`mod_jk`模块: ```apacheconf LoadModule jk_module /path/to/mod_jk.so ``` 请将`/path/to/mod_jk.so`替换为实际的`...
2. **配置Apache**:将`mod_jk.so`放置在Apache的`modules`目录下,并在`httpd.conf`配置文件中加载模块,通过添加`LoadModule jk_module modules/mod_jk.so`指令。 3. **配置JK**:创建或编辑`workers.properties`...
本压缩包提供了实现Tomcat集群配置所需的Apache服务器和mod_jk模块,具体版本为Apache 2.0.55和mod_jk-apache-2.0.55.so。 Apache HTTP Server是一个开源的Web服务器,它能够处理静态HTML文件和动态内容,如PHP、...
1. `httpd.conf`:Apache的主要配置文件,其中包含mod_jk的配置指令。 2. `workers.properties`:定义了Tomcat服务器实例(worker)的属性,如IP地址、端口、连接数限制等。 3. `uriworkermap.properties`:映射URL...
在Apache中启用`mod_jk`,需要在`httpd.conf`配置文件中加载模块,并设置相应的指令。首先,添加`LoadModule jk_module modules/mod_jk.so`来加载模块。然后,使用`JkWorkersFile`指定`worker.properties`的位置,用...
《Apache + Tomcat 整合:mod_jk与反向代理详解》 在Web服务器与应用服务器的集成中,Apache HTTP Server(简称Apache)和Tomcat的组合是常见的选择。Apache作为静态资源处理的专家,而Tomcat则擅长处理Java应用。...
在配置Apache与Tomcat的连接时,我们需要在httpd.conf中添加mod_jk的配置,例如启用mod_jk模块,设置worker定义(这将在workers.properties文件中详细描述)以及虚拟主机或路径的重定向规则。 接下来,workers....
### Apache+mod_jk+Tomcat负载均衡配置详解 #### 一、背景介绍 随着互联网技术的迅猛发展,单一服务器已经难以满足日益增长的服务需求。负载均衡技术应运而生,成为提高服务可用性和扩展性的关键手段之一。本文将...
3. 将mod_jk模块加载到Apache配置文件(httpd.conf)中。 4. 配置worker.properties文件,定义Tomcat实例的属性和负载均衡策略。 5. 修改Tomcat的server.xml文件,添加AJP监听端口。 6. 重启Apache服务器使配置生效...