linux下apache+tomcat集群详细配置
Liunx下Tomcat调优指南

Liunx下Tomcat调优指南1概述由于Tomcat的运行依赖于JVM,从虚拟机的角度我们把Tomcat的调整分为外部环境调优和自身调优两类来描述。
2调优方案1.1外部环境调优1)操作系统性能优化对于操作系统优化来说,是尽可能的增大可使用的内存容量、提高CPU的频率,保证文件系统的读写速率等。
经过压力测试验证,在并发连接很多的情况下,CPU的处理能力越强,系统运行速度越快。
对于并发数很大的情况来说,带宽也是影响系统性能的一个重要指标,因此要实现系统的快速响应,必须拥有较高的带宽。
建议使用64位操作系统,如果是32位操作系统,建议使用企业版。
2)JAVA虚拟机性能优化Tomcat需要依赖Java虚拟机运行。
根据客户选用的主机的操作系统选择对应的JDK 的版本。
无论哪个厂商的JDK,都建议使用最新的版本。
虚拟机可通过命令行的方式改变虚拟机使用内存的大小。
如下表所示有两个参数用来设置虚拟机使用内存的大小。
Tomcat默认可以使用的内存为128MB,在较大型的应用项目中,这点内存是不够的,需要调大。
Windows下,在文件% TOMCAT_HOME %/bin/catalina.bat,Unix下,在文件$TOMCAT_HOME/bin/catalina.sh的前面,增加如下设置:JAVA_OPTS=’-Xms【初始化内存大小】-Xmx【可以使用的最大内存】’需要把这个两个参数值调大。
例如:JAVA_OPTS='-Xms256m -Xmx512m',表示初始化内存为256MB,可以使用的最大内存为512MB。
另外需要考虑的是Java提供的垃圾回收机制。
虚拟机的堆大小决定了虚拟机花费在收集垃圾上的时间和频度。
收集垃圾可以接受的速度与应用有关,应该通过分析实际的垃圾收集的时间和频率来调整。
如果堆的空间很大,那么完全垃圾收集(FULL GC)就会很慢,但是频度会降低。
如果在客户系统中把堆的大小和内存的需要一致,完全收集就很快,但是会更加频繁。
Linux下Apache服务的部署和配置

Linux下Apache服务的部署和配置⽬录1 Apache的作⽤2 Apache的安装3 apache的启⽤4 apache的基本信息5 apache的访问控制5.1 基于客户端ip的访问控制5.2 基于⽤户认证的访问控制6 apache的虚拟主机7 apache的加密访问8 ⽹页重写9 正向代理10 反向代理11 apache ⽀持的语⾔1 Apache的作⽤解析⽹页语⾔,如html,php,jsp等接收web⽤户的请求,并给予⼀定的响应2 Apache的安装安装apche软件:dnf install httpd.x86_64 -y3 apache的启⽤开启apache服务并设置开机启动:systemctl enable --now httpd查看apache服务的状态:systemctl enable --now httpd查看⽕墙信息:firewall-cmd --list-all 在⽕墙中永久开启http服务:firewall-cmd --permanent --add-service=http在⽕墙中永久开启https服务: f irewall-cmd --permanent --add-service=https在不改变当前⽕墙状态的情况下刷新防⽕墙:firewall-cmd --reload4 apache的基本信息apche的基本信息服务名称:httpd主配置⽂件:/etc/httpd/conf/httpd.conf⼦配置⽂件:/etc/httpd/conf.d/*.conf默认发布⽬录:/var/www/html默认端⼝:80 (http),443(https)⽇志⽂件:/etc/httpd/logs开启apche服务后,输⼊ip查看默认发布页⾯:(1)更改apche服务的端⼝号查看httpd服务的默认端⼝号:netstat -antlupe |grep httpd编辑配置⽂件:/etc/httpd/conf/httpd.conf,修改端⼝号重启httpd服务:systemctl restart httpd查看httpd服务的端⼝号:netsat -antlupe | grep httpd更改端⼝号后,输⼊ip后⽆法正常连接,原因是8080端⼝未添加在⽕墙中在防⽕墙⾥添加888端⼝号:firewall-cmd --permanent --add-port=888/tcp在不改变当前⽕墙状态的情况下刷新防⽕墙:firewall-cmd --reload输⼊IP地址:端⼝号,可以正常访问(2)修改apche的默认发布⽂件默认⽬录:cd /var/www/html在⽂件默认发布⽬录下新建⼀个⽂件index.html输⼊:http://172.25.254.144查看默认发布⽂件就是访问apache时没有指定⽂件名,即默认访问的⽂件,此⽂件可以指定多个,但有访问顺序。
tomcat配置手册

以下部署方式都是针对tomcat5.0以上版本。
Tomcat4中的Manager和Admin管理工具其实就是利用它来部署的。
在Tomcat5中提出了Context descriptor这个概念,且为其配置了一个专有目录,而不像Tomcat4那样大杂烩一般地放置在$appBase目录下。
Context descriptor是一个只包含Context元素的xml格式的部署文件,其中Context元素与server.xml中的Context元素配置相同。
对于一个给定的主机,Context descriptor放置在$CATALINA_HOME/conf/[enginename]/[hostname]/目录下面。
Tomcat5默认安装时,在$CATALINA_HOME/conf/Catalina/localhost目录中有admin.xml和manager.xml,是两个管理工具的部署描述符文件。
而这两个文件在Tomcat4中是放置在$CATALINA_HOME/webapps目录下面的。
使用方法:(1)在$CATALINA_HOME/conf/[enginename]/[hostname]/目录下新建xxx.xml文档(2)在xxx.xml文档中配置如下<Context docBase="${catalina.home}/server/webapps/host-manager"privileged="true" antiResourceLocking="false" antiJARLocking="false"> </Context>注:docBase也可以设置为[eclipse的workplace]/[project]/webroot静态部署是指在Tomcat运行之前就把相关的Web应用程序放置到合适的目录,在Tomcat启动的时候自动来部署这些应用程序。
apache 和tomcat 整合的基本步骤

apache 和tomcat 整合的基本步骤Apache和Tomcat是Java Web开发中常用的两个服务器软件,通过整合Apache和Tomcat可以提高Web应用的性能和安全性。
下面将介绍Apache和Tomcat整合的基本步骤。
1. 安装Apache首先需要安装Apache服务器。
可以从官方网站或其他信任的下载源下载最新稳定版的Apache服务器软件。
安装过程中需要指定安装路径,并确保Apache服务器可以正常运行。
2. 安装Tomcat接下来需要安装Tomcat服务器。
同样可以从官方网站或其他信任的下载源下载最新稳定版的Tomcat服务器软件。
安装过程中需要指定安装路径,并确保Tomcat服务器也可以正常运行。
3. 配置Apache和Tomcat完成安装后,需要进行一些配置工作。
首先找到Apache的配置文件httpd.conf,通常位于Apache安装目录的conf文件夹中。
在该文件中添加以下配置信息:LoadModule jk_module modules/mod_jk.soJkWorkersFile conf/workers.propertiesJkLogFile logs/mod_jk.logJkLogLevel infoJkLogStampFormat这些配置信息用于加载与Tomcat整合相关的模块,并设置相关日志文件和级别。
4. 配置workers.properties接着需要创建workers.properties文件,该文件用于配置与Tomcat 连接的工作进程。
在配置文件中添加以下配置信息:worker.list=worker1worker.worker1.type=ajp13worker.worker1.host=localhostworker.worker1.port=8009在这里我们配置了一个名为worker1的工作进程,指定了连接的类型为AJP13,主机为localhost,端口为Tomcat服务器配置的AJP连接端口,默认为8009。
Linux下Apache的安装与配置

Linux下Apache的安装与配置⼀、编译安装1、解决依赖关系⼆、后续操作1、启动httpd两种⽅法:第⼀种、/usr/local/apache/bin/apachectl start第⼆种⽅法:先修改http.pid⽂件位置打开配置⽂件增加⼀⾏vim /etc/httpd/httpd.conf 增加PidFile “/var/run/httpd.pid”为了启动httpd更加⽅便,#!/bin/bash## httpd Startup script for the Apache HTTP Server## chkconfig: - 85 15# description: Apache is a World Wide Web server. It is used to serve \# HTML files and CGI.# processname: httpd# config: /etc/httpd/conf/httpd.conf# config: /etc/sysconfig/httpd# pidfile: /var/run/httpd.pid# Source function library.. /etc/rc.d/init.d/functionsif [ -f /etc/sysconfig/httpd ]; then. /etc/sysconfig/httpdfi# Start httpd in the C locale by default.HTTPD_LANG=${HTTPD_LANG-"C"}# This will prevent initlog from swallowing up a pass-phrase prompt if# mod_ssl needs a pass-phrase from the user.INITLOG_ARGS=""# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server# with the thread-based "worker" MPM; BE WARNED that some modules may not# work correctly with a thread-based MPM; notably PHP will refuse to start.# Path to the apachectl script, server binary, and short-form for messages.apachectl=/usr/local/apache/bin/apachectlhttpd=${HTTPD-/usr/local/apache/bin/httpd}prog=httpdpidfile=${PIDFILE-/var/run/httpd.pid}lockfile=${LOCKFILE-/var/lock/subsys/httpd}RETVAL=0start() {echo -n $"Starting $prog: "LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONSRETVAL=$?echo[ $RETVAL = 0 ] && touch ${lockfile}return $RETVAL}stop() {echo -n $"Stopping $prog: "killproc -p ${pidfile} -d 10 $httpdRETVAL=$?echo[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}}reload() {echo -n $"Reloading $prog: "if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; thenRETVAL=$?echo $"not reloading due to configuration syntax error"failure $"not reloading $httpd due to configuration syntax error"elsekillproc -p ${pidfile} $httpd -HUPRETVAL=$?fiecho}# See how we were called.case "$1" instart)start;;stop)stop;;status)status -p ${pidfile} $httpdRETVAL=$?;;restart)stopstart;;condrestart)if [ -f ${pidfile} ] ; thenstopstartfi;;reload)reload;;graceful|help|configtest|fullstatus)$apachectl $@RETVAL=$?;;*)echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}" exit 1esacexit $RETVAL将以上代码加⼊到vim /etc/init.d/httpd中⽽后为此脚本赋予执⾏权限:chmod +x /etc/rc.d/init.d/httpd加⼊服务列表:chkconfig --add httpd给3,5启动chkconfig --level 3,5 httpd on最后加路径将 export PATH=$PATH:/usr/local/apache/binvim /etc/profile.d/httpd.sh完成后重新登录就可以了。
Apache与tomcat的整合、负载均衡和加入启动和系统服务

Apache与tomcat的整合及负载均衡系统环境:Windows Server 2021 R2 SP1虚拟机环境:Red Hat Enterprise Linux Server release 5.4 (Tikanga) X64安装软件版本:JDK:1.6.0_19 Tomcat: Apache: JK:实施步调:一、安装软件。
1tar -xz2345./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=most--with-mpm=worker6make7make install89/jk/native/1011./configure --with-apxs=/usr/local/apache2/bin/apxs12make13make install二、配置整合及负载均衡1 cp / /usr/local/apache2/modules2配置环境变量vi /etc/profile在文本末尾参加以下内容JAVA_HOME=JDK安装路径CATALINA_HOME=tomcat安装路径CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.PATH=$JAVA_HOME/bin:$PATHexport JAVA_HOME CATALINA_HOME CLASSPATH PATH3应用初始的环境变量source /etc/profile4点窜以下几处而且在末尾加上:Include /usr/local/apache2/conf/ 5添加及设置vi /usr/local/apache2/增加以下内容#加载mod_jk ModuleJkLogLevel info载分配控制制器JkMount /* lb6添加及设置vi /usr/local/apache2/conf/添加以下内容worker.list = lb,tomcat1,tomcat2#server 列表#========tomcat1========worker.tomcat1.port=8009#ajp13 端标语,在tomcat下server.xml配置,默认8009#tomcat的主机地址,如不为本机,请填写ip地址worker.tomcat1.type=ajp13worker.tomcat1.lbfactor = 1#server的加权比重,值越高,分得的请求越多#========tomcat2========worker.tomcat2.port=8009#ajp13 端标语,在tomcat下server.xml配置,默认8009#tomcat的主机地址,如不为本机,请填写ip地址worker.tomcat2.type=ajp13worker.tomcat2.lbfactor = 1#server的加权比重,值越高,分得的请求越多#========controller,负载均衡控制器========worker.lb.type=lbworker.lb.balanced_workers=tomcat1,tomcat2#指定分担请求的tomcatworker.lb.sticky_session=17、将JSP文件放入/usr/local/tomcat/webapps/ROOT8 启动apache和tomcat8 翻开浏览器输入就是这么简单。
Linux下配置tomcat+https

keystorePass="hellohello"
clientAuth="false" sslProtocol="TLS" />
[root@localhost ~]# mv jdk1.5.0_19 /usr/local/
[root@localhost local]# ln -s jdk1.5.0_19 jdk
下面是配置路径:
[root@localhost local]# vi /etc/profile
在文件的最后加入:
[Unknown]: suzhou
What is the two-letter country code for this unit?
[Unknown]: cn
Is CN=liu, OU=bea, O=bea, L=suzhou, ST=suzhou, C=cn correct?
catalina-tasks.xml digest.sh setclasspath.bat startup.sh tool-wrapper.bat
commons-daemon.jar jkstatus-tasks.xml setclasspath.sh tomcat5.exe tool-wrapper.sh
[root@localhost tomcat5.5]# ls
bin common conf LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt server shared temp webapps work
Linux平台Apache高可用双机集群Tomcat负载均衡集群配置手册

Linux平台Apache双机高可用集群+ Tomcat负载均衡集群配置手册在这个配置手册中,使用的操作系统和软件清单如下:操作系统:RedHat Enterprise Linux AS4 U4 64bit(安装时最好选择完全安装)软件:jdk-1_5_0_15-linux-amd64.binTomcat5.5.26httpd-2.0.63.tar.gzjakarta-tomcat-connectors-jk2-src-current.tar.gzipvsadm-1.24.tar.gzlibnet.tar.gzheartbeat-2.1.3-3.el4.centos.x86_64.rpmheartbeat-pils-2.1.3-3.el4.centos.x86_64.rpmheartbeat-stonith-2.1.3-3.el4.centos.x86_64.rpm因为是linux操作系统,所以在安装软件时请使用对应自己操作系统内核的软件,这是整个集群成功的第一步。
本配置手册中的软件都是对应RedHat Enterprise Linux AS4 U4 64bit 这个版本的软件。
jdk-1_5_0_15-linux-amd64.binJAVA环境包使用的是64位1.5版Tomcat版本为公司指定的5.5版本Apache为2.0.63版jakarta-tomcat-connectors-jk2-src-current.tar.gz是连接Apache和Tomcat的连接插件,具体可以去Tomcat网站上查找下载ipvsadm-1.24.tar.gzlibnet.tar.gz这两个是用于2台Apache服务器虚拟一个IP地址使用heartbeat-2.1.3-3.el4.centos.x86_64.rpmheartbeat-pils-2.1.3-3.el4.centos.x86_64.rpmheartbeat-stonith-2.1.3-3.el4.centos.x86_64.rpm这3个软件是用于2台Apache服务器之间的心跳检测结构图Apache1以以以以以Tomcat1Tomcat2Apache22台Tomcat服务器使用Tomcat软件可以自己做集群,2台Apache服务器需要其他的软件实现虚拟服务器功能,工作站访问虚拟IP地址访问2台Apache服务器,再通过Apache服务器访问Tomcat服务器第3 页总13 页1.安装JAVA环境包1)输入命令:./ jdk-1_5_0_15-linux-amd64.bin执行完毕后,会在当前目录下生成一个JDK-1.5.0_15的文件夹2)在 /usr/local/下新建一个名字为JAVA文件夹,将个JDK-1.5.0_15的文件夹拷入到该文件夹下3)设置环境变量。
linux-Apache 配置

Apache 配置一、安装Apache下载地址:/1. 安装Apache# tar zxvf httpd-2.2.11.tar.gz# cd httpd-2.2.11# ./configure --prefix=/usr/local/apache --enable-so//编译时加上加载模块参数--enable-so# make# make install2. 配置系统启动时自动启动Apache服务。
# vi /etc/rc.d/rc.local//在rc.local上加入一行/usr/local/apache/bin/apachectl –k start。
二、配置Apache1. 修改httpd.conf文件# vi /usr/local/apache/conf/httpd.conf1)设置根目录的路径根目录是指Apache存放配置文件和日志文件的目录,配置参数为ServerRoot,默认位于“/u sr/local/apache”。
命令如下:2)设置监听IP地址及端口号默认侦听本机所有IP地址的TCP80端口,命令如下:Listen 80用户也可以按自己的需求,使用多个Listen语句在多个地址和端口上侦听客户端请求。
比如:Listen 192.168.99.9:80Linsten 172.16.0.20:80803)设置系统管理员E-m ail使用ServerAdmin参数设置管理员E-m ail,比如管理员的Email地址为root@guoxuemin. cn:4)设置服务器主机的名称参数ServerName用来设置服务器的主机名称,如果没有域名则填入服务器的IP地址,比如服务器的IP地址为192.168.99.9:5)设置主目录的路径用户可以使用参数Document Root配置服务器主目录默认路径,比如,主目录路径为:6)设置默认文件Apache的默认文件名为index.ht ml,可以使用Directory Index参数来配置,比如,将ind ex.php设置为默认文件名:7)测试:打开浏览器,输入地址:http://192.168.99.9,可以打开站点了:2. 配置目录权限使用<Directory 目录路径>和</Directory>设置目录的权限。
Apache2.2+tomcat-6.0.18集群部署手册

一、软件准备Apache 2.2Tomcat-6.0.18:mod_jk-1.2.31-httpd-2.2.3.sojdk-1_5_0_06-windows-i586-p.exe注意:由于Apache和Tomcat项目与集群相关的模块均处于持续发展和优化过程中,因此笔者不保证本文配置方法对所有Apache和Tomcat版本均适用。
二、Apache安装1、先准备好软件:2、安装Apache,配置成功一个普通网站服务器3、运行下载好的“httpd-2.2.19-win32-x86-openssl-0.9.8r.msi”,出现如下界面:4、出现Apache HTTP Server 2.0.55的安装向导界面,点“Next”继续5、确认同意软件安装使用许可条例,选择“I accept the terms in the license agreement”,点“Next”继续6、将Apache安装到Windows上的使用须知,请阅读完毕后,按“Next”继续7、设置系统信息,在Network Domain下填入您的域名(比如:),在Server Name下填入您的服务器名称(比如:,也就是主机名加上域名),在Administrator's Email Address下填入系统管理员的联系电子邮件地址(比如:yinpeng@),上述三条信息仅供参考,其中联系电子邮件地址会在当系统故障时提供给访问者,三条信息均可任意填写,无效的也行。
下面有两个选择,图片上选择的是为系统所有用户安装,使用默认的80端口,并作为系统服务自动启动;另外一个是仅为当前用户安装,使用端口8080,手动启动。
一般选择如图所示。
按“Next”继续。
]8、选择安装类型,Typical为默认安装,Custom为用户自定义安装,我们这里选择Custom,有更多可选项。
按“Next”继续9、出现选择安装选项界面,如图所示,左键点选“Apache HTTP Server 2.0.55”,选择“This feature, and all subfeatures, will be installed on local hard drive.”,即“此部分,及下属子部分内容,全部安装在本地硬盘上”。
linux tomcat jvm参数

在Linux系统下,可以通过修改Tomcat的启动脚本设置JVM参数。
具体步骤如下:
1. 打开Tomcat的启动脚本(通常是catalina.sh或catalina.bat),通常位于Tomcat安装目录下的bin文件夹中。
2. 在脚本中找到JAVA_OPTS或CATALINA_OPTS这一行,如果这一行不存在,可以在脚本开头添加一行。
3. 在该行中设置JVM参数,例如:
* -Xms512m:设置Java堆的初始大小为512MB。
* -Xmx1024m:设置Java堆的最大大小为1024MB。
* -Xss2m:设置每个线程的堆栈大小为2MB。
* -XX:MaxPermSize=256m:设置永久代的最大大小为256MB(仅适用于Java 7及更早版本)。
4. 保存并关闭启动脚本。
5. 重新启动Tomcat服务器,使设置生效。
请注意,JVM参数的具体设置取决于应用程序的需求和可用资源。
以上参数只是一个示例,您可以根据实际情况进行调整。
另外,请确保您具有足够的系统资源来支持所设置的JVM参数,以避免系统资源不足的问题。
Linux下apache2.2.15+tomcat6.0.26+jdk-6u20安装配置文档

apache2.2.15+tomcat6.0.26+jdk-6u20+tomcat-connectors-1.2.30+ apr-1.4.2.tar.gz+ apr-util-1.3.9.tar.gz[root@hostserver Tools]# lltotal 125304-rw-r--r-- 1 root root 6123410 Apr 19 06:16 apache-tomcat-6.0.26.tar.gz-rw-r--r-- 1 root root 6593633 Apr 19 06:16 httpd-2.2.15.tar.gz-rw-r--r-- 1 root root 9280000 Apr 19 06:16 apr-1.4.2.tar.gz-rw-r--r-- 1 root root 7730000 Apr 19 06:16 apr-util-1.3.9.tar.gz-rw-r--r-- 1 root root 84796967 Apr 19 06:18 jdk-6u20-linux-i586.bin-rw-r--r-- 1 root root 29050568 Jan 23 12:13 mysql-5.1.30.tar.tar-rw-r--r-- 1 root root 1566749 Apr 19 06:16 tomcat-connectors-1.2.30-src.tar.gz[root@hostserver Tools]# cp jdk-6u20-linux-i586.bin /usr/local/[root@hostserver Tools]# cp httpd-2.2.15.tar.gz /usr/local/[root@hostserver Tools]# cp apache-tomcat-6.0.26.tar.gz /usr/local/[root@hostserver Tools]# cp tomcat-connectors-1.2.30-src.tar.gz /usr/local/[root@hostserver Tools]# cp mysql-5.1.30.tar.tar /usr/local/[root@hostserver Tools]# cd /usr/local/[root@hostserver Tools]# cd /usr/local/所有包都在此目录下[root@hostserver local]# ll-rw-r--r-- 1 root root 84796967 Apr 19 07:33 jdk-6u20-linux-i586.bin-rw-r--r-- 1 root root 6593633 Apr 19 07:33 httpd-2.2.15.tar.gz-rw-r--r-- 1 root root 6123410 Apr 19 07:33 apache-tomcat-6.0.26.tar.gz-rw-r--r-- 1 root root 1566749 Apr 19 07:33 tomcat-connectors-1.2.30-src.tar.gz-rw-r--r-- 1 root root 29050568 Apr 19 07:33 mysql-5.1.30.tar.tar第一步:安装JDK[root@hostserver local]# chmod 755 jdk-6u20-linux-i586.bin[root@hostserver local]# ./jdk-6u20-linux-i586.bin……Please enter "yes" or "no".Do you agree to the above license terms? [yes or no]输入Yes,并按[enter]键.Press Enter to continue.....再次按[enter]键,则JDK安装完成。
Tomcat8.5安装和配置

notifyListenersOnReplication="true"/>
<Channel className="org.apache.catalina.tribes.group.GroupChannel">
xsi:schemaLocation="/xml/ns/javaee
/xml/ns/javaee/web-app_3_1.xsd"
version="3.1"
metadata-complete="true">
</Sender>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor"/>
watchDir="/tmp/war-listen/"
watchEnabled="false"/>
<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
scp 10.32.35.100:/data/share/jdk-8u111-linux-x64.tar.gz /opt/tomcat
Linux搭建Apache+Tomcat环境(详细文档)

Linux搭建Apache+Tomcat环境使用手册(仅供内部使用)V1.0目录目录 (1)1 引言 (3)1.1 编写目的 (3)1.2 项目背景 (3)1.3 定义 (3)1.3.1 集群(Cluster) (3)1.3.2 负载均衡(Load Balance) (3)1.4 参考资料 (3)1.5 变更历史 (3)2 技术介绍 (3)2.1 技术目标 (3)2.2 网络架构 (3)2.3 软件架构 (4)3 客户端软件准备 (4)3.1 Tomcat: (4)3.2 Apache: (4)3.3 Jk: (4)4 测试环境规划 (4)4.1 Apache集群程序 (4)4.2 Tomcat1程序(内容+后台统一部署) (4)4.3 Tomcat2程序(内容+后台统一部署) (5)5 详细步骤 (5)5.1 安装JDK (5)5.1.1 jdk1.5.0_19 (5)5.1.2 配置环境变量 (6)5.1.3 测试Java是否安装成功 (6)5.2 安装Tomcat (6)5.2.1 Tomcat环境准备 (6)5.2.2 配置环境变量 (7)5.2.3 测试Tomcat是否安装成功 (7)5.2.4 部署工程项目 (7)5.3 安装Apache (7)5.3.1 apache环境准备 (8)5.3.2 httpd-2.2.12.tar.gz (8)5.3.3 测试Apache是否安装成功 (8)5.4 集群和负载均衡的配置 (9)5.5 修改httpd.conf (9)5.6 安装mod_jk.so (9)5.7 建立mod_jk.conf文件 (10)5.8 建立workers.properties文件 (10)5.9 建立uriworkermap.properties (11)5.10 综合测试Apache + Tomcat (11)6 总结 (12)6.1 绑定的域名 (12)6.2 编译出so文件 (12)6.3 设置Apache和Tomcat随系统启动而自动启动: (12)6.3.1 Red Hat的配置 (12)6.3.2 Ubuntu 的配置 (12)6.4 不足之处,见谅! (12)7 附录 (13)7.1 Tomcat集群与负载均衡区别以及特性 (13)7.2 ubuntu 配置开机启动vnc (15)1 引言1.1 编写目的本说明手册为了阐述Linux搭建Apache+Tomcat环境,并详细介绍Tomcat的集群和负载均衡配置而编写。
如何在Linux上安装和配置Tomcat服务器

如何在Linux上安装和配置Tomcat服务器Tomcat是一个开源的Java Servlet容器,它提供了一个实现Java服务并运行Java Web应用程序的环境。
在Linux操作系统上,安装和配置Tomcat服务器是常见的任务之一。
本文将介绍如何在Linux上安装和配置Tomcat服务器的步骤。
一、安装JDK在安装Tomcat之前,需要先安装Java Development Kit(JDK)。
可以从Oracle官方网站下载最新版本的JDK,并根据Linux的系统架构选择正确的安装包。
下载完成后,执行安装过程并设置JAVA_HOME环境变量。
二、下载Tomcat访问Tomcat官方网站,选择最新版本的Tomcat并下载。
下载完成后,将Tomcat压缩包解压到合适的目录中。
例如,可以将Tomcat解压到`/opt`目录下。
三、配置环境变量打开终端,使用编辑器(如vi或nano)打开`~/.bashrc`文件,并添加以下内容:```export CATALINA_HOME=/opt/apache-tomcat-x.x.xexport PATH=$PATH:$CATALINA_HOME/bin```保存并退出文件。
然后使用以下命令使环境变量生效:```source ~/.bashrc```四、配置Tomcat用户为了增加安全性,可以创建一个专门用于运行Tomcat的用户。
在终端中执行以下命令来创建一个新用户:```sudo adduser tomcat```根据提示设置新用户的密码。
五、修改Tomcat目录权限为了保护Tomcat目录的安全性,需要将所有者设置为刚刚创建的`tomcat`用户。
使用以下命令修改目录权限:```sudo chown -R tomcat:tomcat /opt/apache-tomcat-x.x.x```六、启动Tomcat现在,可以启动Tomcat服务器了。
在终端中执行以下命令:```cd /opt/apache-tomcat-x.x.x/bin./startup.sh```七、配置防火墙如果启用了防火墙,需要打开Tomcat所使用的端口。
ApacheTomcat下载、安装、配置图文教程

ApacheTomcat下载、安装、配置图⽂教程Tomcat安装配置欢迎我的博客。
Tomcat是Apache 软件基⾦会(Apache Software Foundation)的Jakarta 项⽬中的⼀个核⼼项⽬,由Apache、Sun 和其他⼀些公司及个⼈共同开发⽽成。
由于有了Sun 的参与和⽀持,最新的Servlet 和JSP 规范总是能在Tomcat 中得到体现,Tomcat 5⽀持最新的Servlet 2.4 和JSP 2.0 规范。
因为Tomcat 技术先进、性能稳定,⽽且免费,因⽽深受Java 爱好者的喜爱并得到了部分软件开发商的认可,成为⽬前⽐较流⾏的Web 应⽤服务器。
Tomcat官⽹Apache Tomcat - Welcome!Tomcat下载安装Tomcat下载9.0.0.M4下载地址:注意:下载可以下载zip格式或exe格式的,其中zip格式的只要解压缩再配置下环境变量就可以使⽤了,就像绿⾊版的。
我这⾥使⽤的是后者exe格式的,这个对于新⼿⽐较⽅便。
点击32-bit/64-bit Windows Service Installer下载Tomcat安装安装很简单下⼀步下⼀步注意安装之前要有Java环境点击Finish可以看到Tomcat服务启动了打开浏览器,敲⼊,如果出现页⾯,那么配置成功。
Tomcat配置Tomcat环境配置并⾮必须下⾯默认已经配置好Java环境。
新建变量在桌⾯此电脑右键、左上⾓⾼级系统设置、⾼级选项卡、环境变量、系统变量下新建以下变量:⽐如Tomcat安装在C:\Tomcat,其他⽬录替换C:\Tomcat即可。
变量名:CATALINA_BASE变量值:C:\Tomcat;变量名:CATALINA_HOME变量值:C:\Tomcat;添加变量在PATH中加⼊%CATALINA_HOME%\bin;在CLASSPATH中加⼊(如果没此变量,按照上步新建即可)%CATALINA_HOME%\common\lib\servlet-api.jar;(注意加的时候在原变量值后加英⽂状态下的“;”)其他问题安装tomcat出现failed to install tomcat8 service错误及解决⽅法在安装tomcat时,报failed to install tomcat6 service ,check your setting and permissio错误。
linux下安装apache的及反向代理配置完整过程

下面是linux下安装apache的完整代码,系统是redhat5.51、检查系统防火墙有没开,需要把防火墙关掉,可以执行SETUP查看,关闭。
在开启了防火墙时,做如下设置,开启相关端口,修改/etc/sysconfig/iptables 文件,添加以下内容:-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8088 -j ACCEPT 2、安装Apache下载地址:</>1. 安装Apache# tar zxvf httpd-2.2.22.tar.gz //解压文件# cd httpd-2.2.22//进入安装文件夹#./configure --prefix=/usr/local/apache --enable-so--enable-mods-shared=most --enable-proxy --enable-proxy-connect--enable-proxy-ftp --enable-proxy-http --enable-proxy-scgi--enable-proxy-ajp --enable-proxy-balancer // 配置apache路径加载动态模块# make //编译apache# make install//安装apache其它相关命令:下载httpd-2.2.22.tar.bz2 把httpd-2.2.22.tar.bz2放到/soft 下[root@localhost ~]#cd /soft[root@localhost soft]#tar jxvf httpd-2.2.6.tar.bz2 //解压apache的压缩包[root@localhost soft]#cd httpd-2.2.6 //定位到httpd-2.2.6 文件夹下[root@localhost httpd-2.2.6]#ls //查看显示httpd-2.2.6 文件夹下内容 [root@localhost httpd-2.2.6]# ./configure --help | more //查看安装apache配置参数[root@localhost httpd-2.2.6]#./configure --prefix=/usr/local/apache --enable-so // 配置apache路径[root@localhost httpd-2.2.6]#./configure --prefix=/usr/local/apache--enable-so --enable-mods-shared=most --enable-proxy--enable-proxy-connect --enable-proxy-ftp --enable-proxy-http--enable-proxy-scgi --enable-proxy-ajp --enable-proxy-balancer// 配置apache路径加载动态模块[root@localhost httpd-2.2.6]#make //编译apache[root@localhost httpd-2.2.6]#make install //安装apache[root@localhost httpd-2.2.6]#cd /usr/local/apache //进入apache的目录[root@localhost apache]# cd conf/[root@localhost conf]#cp httpd.conf httpd.conf_bak //备份apache配置文件[root@localhost conf]#chkconfig --list httpd //查看httpd服务是否已存在[root@localhost conf]#chkconfig httpd off //关闭系统自带了httpd的服务,如果存在httpd服务[root@localhost conf]#service httpd status //查看自带httpd服务状态[root@localhost conf]# /usr/local/apache/bin/apachectl -k start//linux启动apache命令[root@localhost conf]# /usr/local/apache/bin/apachectl -k stop //linux 停止apache命令[root@localhost conf]#netstat -an | grep :80 //查看linux80端口是否开启[root@localhost conf]#ps -aux | grep httpd //linux下查看apache进程[root@localhost conf]#cd ../..[root@localhost local]#cp /usr/local/apache/bin/apachectl/etc/rc.d/init.d/apache //拷贝apache启动脚本[root@localhost local]#vi /etc/rc.d/init.d/apache // 这里是编辑apache 启动脚本在开头的#!/bin/sh 下面加上#chkconfig: 2345 85 15[root@localhost local]#chkconfig --add apache //添加apache服务[root@localhost local]#chkconfig --list apache //列出apache服务[root@localhost local]#service apache stop //停止apache服务[root@localhost local]#netstat -an | grep :80 //查看linux的80端口是否开启[root@localhost local]#ps -aux | grep httpd //查看是否存在httpd服务,若果之前自带httpd服务启动的话会导致新添加的apache服务启动失败[root@localhost local]#service apache start //启动apache服务打开你的服务器ip地址,看看是否出现了tomcat的默认首页,如果出现的话,那么恭喜你linux下安装apache已经成功了3、修改httpd.conf文件vi /usr/local/apache/conf/httpd.conf以下为httpd.conf内容:# This is the main Apache HTTP server configuration file. It contains the # configuration directives that give the server its instructions.# See <URL:/docs/2.2> for detailed information.# In particular, see# <URL:/docs/2.2/mod/directives.html># for a discussion of each configuration directive.## Do NOT simply read the instructions in here without understanding# what they do. They're here only as hints or reminders. If you are unsure # consult the online docs. You have been warned.## Configuration and logfile names: If the filenames you specify for many # of the server's control files begin with "/" (or "drive:/" for Win32), the # server will use that explicit path. If the filenames do *not* begin # with "/", the value of ServerRoot is prepended -- so "logs/foo_log"# with ServerRoot set to "/usr/local/apache" will be interpreted by the # server as "/usr/local/apache/logs/foo_log".## ServerRoot: The top of the directory tree under which the server's# configuration, error, and log files are kept.## Do not add a slash at the end of the directory path. If you point# ServerRoot at a non-local disk, be sure to point the LockFile directive # at a local disk. If you wish to share the same ServerRoot for multiple # httpd daemons, you will need to change at least LockFile and PidFile. #ServerRoot "/usr/local/apache"## Listen: Allows you to bind Apache to specific IP addresses and/or# ports, instead of the default. See also the <VirtualHost># directive.## Change this to Listen on specific IP addresses as shown below to# prevent Apache from glomming onto all bound IP addresses.##Listen 12.34.56.78:80Listen 80Listen 8088 --增加监听端口## Dynamic Shared Object (DSO) Support## To be able to use the functionality of a module which was built as a DSO you# have to place corresponding `LoadModule' lines at this location so the # directives contained in it are actually available _before_ they are used.# Statically compiled modules (those listed by `httpd -l') do not need# to be loaded here.## Example:# LoadModule foo_module modules/mod_foo.so#LoadModule authn_file_module modules/mod_authn_file.so --加载的模块,正确安装完会自动加载以下模块LoadModule authn_dbm_module modules/mod_authn_dbm.soLoadModule authn_anon_module modules/mod_authn_anon.soLoadModule authn_dbd_module modules/mod_authn_dbd.soLoadModule authn_default_module modules/mod_authn_default.soLoadModule authz_host_module modules/mod_authz_host.soLoadModule authz_groupfile_module modules/mod_authz_groupfile.so LoadModule authz_user_module modules/mod_authz_user.soLoadModule authz_dbm_module modules/mod_authz_dbm.soLoadModule authz_owner_module modules/mod_authz_owner.soLoadModule authz_default_module modules/mod_authz_default.soLoadModule auth_basic_module modules/mod_auth_basic.soLoadModule auth_digest_module modules/mod_auth_digest.soLoadModule dbd_module modules/mod_dbd.soLoadModule dumpio_module modules/mod_dumpio.soLoadModule reqtimeout_module modules/mod_reqtimeout.soLoadModule ext_filter_module modules/mod_ext_filter.soLoadModule include_module modules/mod_include.soLoadModule filter_module modules/mod_filter.soLoadModule substitute_module modules/mod_substitute.soLoadModule deflate_module modules/mod_deflate.soLoadModule log_config_module modules/mod_log_config.soLoadModule logio_module modules/mod_logio.soLoadModule env_module modules/mod_env.soLoadModule expires_module modules/mod_expires.soLoadModule headers_module modules/mod_headers.soLoadModule ident_module modules/mod_ident.soLoadModule setenvif_module modules/mod_setenvif.soLoadModule version_module modules/mod_version.soLoadModule proxy_module modules/mod_proxy.soLoadModule proxy_connect_module modules/mod_proxy_connect.soLoadModule proxy_ftp_module modules/mod_proxy_ftp.soLoadModule proxy_http_module modules/mod_proxy_http.soLoadModule proxy_scgi_module modules/mod_proxy_scgi.soLoadModule proxy_ajp_module modules/mod_proxy_ajp.soLoadModule proxy_balancer_module modules/mod_proxy_balancer.so LoadModule mime_module modules/mod_mime.soLoadModule dav_module modules/mod_dav.soLoadModule status_module modules/mod_status.soLoadModule autoindex_module modules/mod_autoindex.soLoadModule asis_module modules/mod_asis.soLoadModule info_module modules/mod_info.soLoadModule cgi_module modules/mod_cgi.soLoadModule dav_fs_module modules/mod_dav_fs.soLoadModule vhost_alias_module modules/mod_vhost_alias.soLoadModule negotiation_module modules/mod_negotiation.soLoadModule dir_module modules/mod_dir.soLoadModule imagemap_module modules/mod_imagemap.soLoadModule actions_module modules/mod_actions.soLoadModule speling_module modules/mod_speling.soLoadModule userdir_module modules/mod_userdir.soLoadModule alias_module modules/mod_alias.soLoadModule rewrite_module modules/mod_rewrite.soTimeout 300 --新增的配置参数KeepAlive OnMaxKeepAliveRequests 1000KeepAliveTimeout 15UseCanonicalName OffAccessFileName .htaccessServerTokens FullServerSignature OnHostnameLookups Off<IfModule !mpm_netware_module><IfModule !mpm_winnt_module>## If you wish httpd to run as a different user or group, you must run # httpd as root initially and it will switch.## User/Group: The name (or #number) of the user/group to run httpd as. # It is usually good practice to create a dedicated user and group for # running httpd, as with most system services.#User daemonGroup daemon</IfModule></IfModule>----------------------------------以下内容是新增的关键参数<IfModule mpm_prefork_module>StartServers 40MinSpareServers 40MaxSpareServers 80MaxClients 256MaxRequestsPerChild 10000</IfModule><IfModule mpm_worker_module>StartServers 40MaxClients 2000MinSpareThreads 100MaxSpareThreads 300ThreadsPerChild 200MaxRequestsPerChild 0</IfModule>ProxyRequests OffRewriteEngine onRewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)RewriteRule .* - [F]RewriteEngine onRewriteCond %{HTTP:range} !(^bytes=[^,]+(,[^,]+){0,4}$|^$)RewriteRule .* - [F]TraceEnable off#NameVirtualHost 10.46.85.137:9080#<VirtualHost 10.46.85.137:9080>#ServerName 10.46.85.137:9080#ProxyPass /ponApp/ http://10.209.122.40:7001/xponApp/#ProxyPassReverse /ponApp/ http://10.209.122.40:7001/xponApp/#</VirtualHost>NameVirtualHost 10.46.85.137:8088<VirtualHost 10.46.85.137:8088>ServerName kuangdai --kuangdai LINUX系统的主机名ProxyPass /xponApp/ http://10.209.122.40:7001/xponApp/ ProxyPassReverse /xponApp/ http://10.209.122.40:7001/xponApp/启动服务报错--/etc/hosts 增加127.0.0.1 localhost.localdomainlocalhost ”kuangdai“主机名</VirtualHost><Proxy *>--配置反向代理的访问权限Order deny,allowAllow from all</Proxy>-----------------------------以上内容是新增的关键参数# 'Main' server configuration## The directives in this section set up the values used by the 'main'# server, which responds to any requests that aren't handled by a# <VirtualHost> definition. These values also provide defaults for# any <VirtualHost> containers you may define later in the file.## All of these directives may appear inside <VirtualHost> containers,# in which case these default settings will be overridden for the# virtual host being defined.### ServerAdmin: Your address, where problems with the server should be# e-mailed. This address appears on some server-generated pages, such # as error documents. e.g. admin@#ServerAdmin you@## 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 127.0.0.1:80 --这个ServerName可随意配置一定去掉前面### 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 "/usr/local/apache/htdocs"## Each directory to which Apache has access can be configured with respect # to which services and features are allowed and/or disabled in that# directory (and its subdirectories).## First, we configure the "default" to be a very restrictive set of# features.#<Directory />Options FollowSymLinksAllowOverride NoneOrder deny,allowDeny from all</Directory>## Note that from this point forward you must specifically allow# particular features to be enabled - so if something's not working as # you might expect, make sure that you have specifically enabled it# below.### This should be changed to whatever you set DocumentRoot to.#<Directory "/usr/local/apache/htdocs">## 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 # /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,denyAllow from all</Directory>## DirectoryIndex: sets the file that Apache will serve if a directory# is requested.#<IfModule dir_module>DirectoryIndex index.html</IfModule>## The following lines prevent .htaccess and .htpasswd files from being # viewed by Web clients.#<FilesMatch "^\.ht">Order allow,denyDeny from allSatisfy All</FilesMatch>## ErrorLog: The location of the error log file.# If you do not specify an ErrorLog directive within a <VirtualHost># container, error messages relating to that virtual host will be# logged here. If you *do* define an error logfile for a <VirtualHost> # container, that host's errors will be logged there and not here.#ErrorLog "logs/error_log"## LogLevel: Control the number of messages logged to the error_log.# Possible values include: debug, info, notice, warn, error, crit,# alert, emerg.#LogLevel warn<IfModule log_config_module>## The following directives define some format nicknames for use with # a CustomLog directive (see below).#LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedLogFormat "%h %l %u %t \"%r\" %>s %b" common<IfModule logio_module># You need to enable mod_logio.c to use %I and %OLogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\"\"%{User-Agent}i\" %I %O" combinedio</IfModule>## The location and format of the access logfile (Common Logfile Format). # If you do not define any access logfiles within a <VirtualHost># container, they will be logged here. Contrariwise, if you *do*# define per-<VirtualHost> access logfiles, transactions will be# logged therein and *not* in this file.#CustomLog "logs/access_log" common## If you prefer a logfile with access, agent, and referer information # (Combined Logfile Format) you can use the following directive.##CustomLog "logs/access_log" combined</IfModule><IfModule alias_module>## Redirect: Allows you to tell clients about documents that used to # exist in your server's namespace, but do not anymore. The client # will make a new request for the document at its new location.# Example:# Redirect permanent /foo /bar## Alias: Maps web paths into filesystem paths and is used to# access content that does not live under the DocumentRoot.# Example:# Alias /webpath /full/filesystem/path## If you include a trailing / on /webpath then the server will# require it to be present in the URL. You will also likely# need to provide a <Directory> section to allow access to# the filesystem path.## ScriptAlias: This controls which directories contain server scripts. # ScriptAliases are essentially the same as Aliases, except that# documents in the target directory are treated as applications and # run by the server when requested rather than as documents sent to the # client. The same rules about trailing "/" apply to ScriptAlias# directives as to Alias.#ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"</IfModule><IfModule cgid_module>## ScriptSock: On threaded servers, designate the path to the UNIX# socket used to communicate with the CGI daemon of mod_cgid.##Scriptsock logs/cgisock</IfModule>## "/usr/local/apache/cgi-bin" should be changed to whatever your ScriptAliased# CGI directory exists, if you have that configured.#<Directory "/usr/local/apache/cgi-bin">AllowOverride NoneOptions NoneOrder allow,denyAllow from all</Directory>## DefaultType: the default MIME type the server will use for a document # if it cannot otherwise determine one, such as from filename extensions. # If your server contains mostly text or HTML documents, "text/plain" is # a good value. If most of your content is binary, such as applications # or images, you may want to use "application/octet-stream" instead to # keep browsers from trying to display binary files as though they are # text.#DefaultType text/plain<IfModule mime_module>## TypesConfig points to the file containing the list of mappings from # filename extension to MIME-type.#TypesConfig conf/mime.types## AddType allows you to add to or override the MIME configuration# file specified in TypesConfig for specific file types.##AddType application/x-gzip .tgz## AddEncoding allows you to have certain browsers uncompress# information on the fly. Note: Not all browsers support this.##AddEncoding x-compress .Z#AddEncoding x-gzip .gz .tgz## If the AddEncoding directives above are commented-out, then you# probably should define those extensions to indicate media types: #AddType application/x-compress .ZAddType application/x-gzip .gz .tgz## AddHandler allows you to map certain file extensions to "handlers": # actions unrelated to filetype. These can be either built into the server # or added with the Action directive (see below)## To use CGI scripts outside of ScriptAliased directories:# (You will also need to add "ExecCGI" to the "Options" directive.) ##AddHandler cgi-script .cgi# For type maps (negotiated resources):#AddHandler type-map var## Filters allow you to process content before it is sent to the client. ## To parse .shtml files for server-side includes (SSI):# (You will also need to add "Includes" to the "Options" directive.) ##AddType text/html .shtml#AddOutputFilter INCLUDES .shtml</IfModule>## The mod_mime_magic module allows the server to use various hints from the # contents of the file itself to determine its type. The MIMEMagicFile # directive tells the module where the hint definitions are located.##MIMEMagicFile conf/magic## Customizable error responses come in three flavors:# 1) plain text 2) local redirects 3) external redirects## Some examples:#ErrorDocument 500 "The server made a boo boo."#ErrorDocument 404 /missing.html#ErrorDocument 404 "/cgi-bin/missing_handler.pl"#ErrorDocument 402 /subscription_info.html### MaxRanges: Maximum number of Ranges in a request before# returning the entire resource, or one of the special# values 'default', 'none' or 'unlimited'.# Default setting is to accept 200 Ranges.#MaxRanges unlimited## EnableMMAP and EnableSendfile: On systems that support it,# memory-mapping or the sendfile syscall is used to deliver# files. This usually improves server performance, but must# be turned off when serving from networked-mounted# filesystems or if support for these functions is otherwise# broken on your system.##EnableMMAP off#EnableSendfile off# Supplemental configuration## The configuration files in the conf/extra/ directory can be# included to add extra features or to modify the default configuration of # the server, or you may simply copy their contents here and change as# necessary.# Server-pool management (MPM specific)#Include conf/extra/httpd-mpm.conf# Multi-language error messages#Include conf/extra/httpd-multilang-errordoc.conf# Fancy directory listings#Include conf/extra/httpd-autoindex.conf# Language settings#Include conf/extra/httpd-languages.conf# User home directories#Include conf/extra/httpd-userdir.conf# Real-time info on requests and configuration#Include conf/extra/httpd-info.conf# Virtual hosts#Include conf/extra/httpd-vhosts.conf# Local access to the Apache HTTP Server Manual#Include conf/extra/httpd-manual.conf# Distributed authoring and versioning (WebDAV)#Include conf/extra/httpd-dav.conf# Various default settings#Include conf/extra/httpd-default.conf# Secure (SSL/TLS) connections#Include conf/extra/httpd-ssl.conf## Note: The following must must be present to support# starting without SSL on platforms with no /dev/random equivalent # but a statically compiled-in mod_ssl.#<IfModule ssl_module>SSLRandomSeed startup builtinSSLRandomSeed connect builtin </IfModule>。
Apache2.4+Tomcat7.0整合配置详解

Apache2.4+Tomcat7.0整合配置详解⼀、简单介绍 Apache、TomcatApache HTTP Server(简称 Apache),是 Apache 软件基⾦协会的⼀个开放源码的⽹页服务器,可以在 Windows、Unix、Linux 等操作系统中运⾏是最流⾏的Web服务器软件之⼀。
Apache 反应速度快,运⾏效率⾼,但只⽀持HTML等静态页⾯(加载插件后也可⽀持 PHP 页⾯)。
Apache Tomcat 是由 Apache 软件基⾦协会与 Sun 公司联合开发的⼀款Web服务器,它除了⽀持HTML等静态页⾯外,还⽀持JSP、Servlet 。
在相同的运⾏环境下,Tomcat 对静态页⾯的反应速度没有 Apache 灵敏,整合 Apache 与 Tomcat 能使系统运⾏于⼀个良好环境下,提⾼系统效率。
⼆、软件包下载运⾏环境:Windows 7Apache 2.4 下载:Tomcat 7.0 下载:JDK 6 下载:mod_jk.mo 连接包下载:下载mod_jk时⼀定要看清版本,下载对应的版本如果已有tomcat和jdk,则不⽤另外下载三、Apache 2.4 安装下载的apache2.4如下图所⽰,直接解压到D:\apache-httpd修改⽂件D:\apache-httpd\conf\httpd.conf,端⼝改为8000,程序⽬录指定为E:\apache-tomcat-7.0.50\webapps\ROOT(即tomcat程序所在⽬录,此⽬录可以修改)ServerRoot "D:/apache-httpd"## Mutex: Allows you to set the mutex mechanism and mutex file directory# for individual mutexes, or change the global defaults## Uncomment and change the directory if mutexes are file-based and the default # mutex file directory is not on a local disk or is not appropriate for some# other reason.## Mutex default:logs## Listen: Allows you to bind Apache to specific IP addresses and/or# ports, instead of the default. See also the <VirtualHost># directive.## Change this to Listen on specific IP addresses as shown below to# prevent Apache from glomming onto all bound IP addresses.##Listen 12.34.56.78:80Listen 8000## Dynamic Shared Object (DSO) Support## To be able to use the functionality of a module which was built as a DSO you # have to place corresponding `LoadModule' lines at this location so the# directives contained in it are actually available _before_ they are used.# Statically compiled modules (those listed by `httpd -l') do not need# to be loaded here.## Example:# LoadModule foo_module modules/mod_foo.so#LoadModule access_compat_module modules/mod_access_compat.so LoadModule actions_module modules/mod_actions.soLoadModule alias_module modules/mod_alias.soLoadModule allowmethods_module modules/mod_allowmethods.so LoadModule asis_module modules/mod_asis.soLoadModule auth_basic_module modules/mod_auth_basic.so#LoadModule auth_digest_module modules/mod_auth_digest.so#LoadModule auth_form_module modules/mod_auth_form.so#LoadModule authn_anon_module modules/mod_authn_anon.so LoadModule authn_core_module modules/mod_authn_core.so#LoadModule authn_dbd_module modules/mod_authn_dbd.so#LoadModule authn_dbm_module modules/mod_authn_dbm.so LoadModule authn_file_module modules/mod_authn_file.so#LoadModule authn_socache_module modules/mod_authn_socache.so#LoadModule authnz_fcgi_module modules/mod_authnz_fcgi.so#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so LoadModule authz_core_module modules/mod_authz_core.so#LoadModule authz_dbd_module modules/mod_authz_dbd.so#LoadModule authz_dbm_module modules/mod_authz_dbm.so LoadModule authz_groupfile_module modules/mod_authz_groupfile.so LoadModule authz_host_module modules/mod_authz_host.so#LoadModule authz_owner_module modules/mod_authz_owner.so LoadModule authz_user_module modules/mod_authz_user.so LoadModule autoindex_module modules/mod_autoindex.so#LoadModule buffer_module modules/mod_buffer.so#LoadModule cache_module modules/mod_cache.so#LoadModule cache_disk_module modules/mod_cache_disk.so#LoadModule cache_socache_module modules/mod_cache_socache.so#LoadModule cern_meta_module modules/mod_cern_meta.so LoadModule cgi_module modules/mod_cgi.so#LoadModule charset_lite_module modules/mod_charset_lite.so#LoadModule data_module modules/mod_data.so#LoadModule dav_module modules/mod_dav.so#LoadModule dav_fs_module modules/mod_dav_fs.so#LoadModule dav_lock_module modules/mod_dav_lock.so#LoadModule dbd_module modules/mod_dbd.so#LoadModule deflate_module modules/mod_deflate.soLoadModule dir_module modules/mod_dir.so#LoadModule dumpio_module modules/mod_dumpio.soLoadModule env_module modules/mod_env.so#LoadModule expires_module modules/mod_expires.so#LoadModule ext_filter_module modules/mod_ext_filter.so#LoadModule file_cache_module modules/mod_file_cache.so#LoadModule filter_module modules/mod_filter.so#LoadModule http2_module modules/mod_http2.so#LoadModule headers_module modules/mod_headers.so#LoadModule heartbeat_module modules/mod_heartbeat.so#LoadModule heartmonitor_module modules/mod_heartmonitor.so#LoadModule ident_module modules/mod_ident.so#LoadModule imagemap_module modules/mod_imagemap.soLoadModule include_module modules/mod_include.so#LoadModule info_module modules/mod_info.soLoadModule isapi_module modules/mod_isapi.so#LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so #LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so #LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so#LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so#LoadModule ldap_module modules/mod_ldap.so#LoadModule logio_module modules/mod_logio.soLoadModule log_config_module modules/mod_log_config.so#LoadModule log_debug_module modules/mod_log_debug.so#LoadModule log_forensic_module modules/mod_log_forensic.so#LoadModule lua_module modules/mod_lua.so#LoadModule macro_module modules/mod_macro.soLoadModule mime_module modules/mod_mime.so#LoadModule mime_magic_module modules/mod_mime_magic.soLoadModule negotiation_module modules/mod_negotiation.soLoadModule proxy_module modules/mod_proxy.soLoadModule proxy_ajp_module modules/mod_proxy_ajp.soLoadModule proxy_balancer_module modules/mod_proxy_balancer.so LoadModule proxy_connect_module modules/mod_proxy_connect.so#LoadModule proxy_express_module modules/mod_proxy_express.so#LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.soLoadModule proxy_ftp_module modules/mod_proxy_ftp.so#LoadModule proxy_html_module modules/mod_proxy_html.soLoadModule proxy_http_module modules/mod_proxy_http.so#LoadModule proxy_http2_module modules/mod_proxy_http2.so#LoadModule proxy_scgi_module modules/mod_proxy_scgi.so#LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so#LoadModule ratelimit_module modules/mod_ratelimit.so#LoadModule reflector_module modules/mod_reflector.so#LoadModule remoteip_module modules/mod_remoteip.so#LoadModule request_module modules/mod_request.so#LoadModule reqtimeout_module modules/mod_reqtimeout.soLoadModule rewrite_module modules/mod_rewrite.so#LoadModule sed_module modules/mod_sed.so#LoadModule session_module modules/mod_session.so#LoadModule session_cookie_module modules/mod_session_cookie.so#LoadModule session_crypto_module modules/mod_session_crypto.so#LoadModule session_dbd_module modules/mod_session_dbd.soLoadModule setenvif_module modules/mod_setenvif.so#LoadModule slotmem_plain_module modules/mod_slotmem_plain.so LoadModule slotmem_shm_module modules/mod_slotmem_shm.so#LoadModule socache_dbm_module modules/mod_socache_dbm.so#LoadModule socache_memcache_module modules/mod_socache_memcache.so#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so LoadModule speling_module modules/mod_speling.soLoadModule ssl_module modules/mod_ssl.so#LoadModule status_module modules/mod_status.so#LoadModule substitute_module modules/mod_substitute.so#LoadModule unique_id_module modules/mod_unique_id.so#LoadModule userdir_module modules/mod_userdir.so#LoadModule usertrack_module modules/mod_usertrack.so#LoadModule version_module modules/mod_version.so#LoadModule vhost_alias_module modules/mod_vhost_alias.so#LoadModule watchdog_module modules/mod_watchdog.so#LoadModule xml2enc_module modules/mod_xml2enc.so<IfModule unixd_module>## If you wish httpd to run as a different user or group, you must run# httpd as root initially and it will switch.## User/Group: The name (or #number) of the user/group to run httpd as.# It is usually good practice to create a dedicated user and group for# running httpd, as with most system services.#User daemonGroup daemon</IfModule># 'Main' server configuration## The directives in this section set up the values used by the 'main'# server, which responds to any requests that aren't handled by a# <VirtualHost> definition. These values also provide defaults for# any <VirtualHost> containers you may define later in the file.## All of these directives may appear inside <VirtualHost> containers,# in which case these default settings will be overridden for the# virtual host being defined.### ServerAdmin: Your address, where problems with the server should be# e-mailed. This address appears on some server-generated pages, such# as error documents. e.g. admin@#ServerAdmin aaa123@## 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 localhost## Deny access to the entirety of your server's filesystem. You must# explicitly permit access to web content directories in other# <Directory> blocks below.#<Directory />AllowOverride noneRequire all denied</Directory>## Note that from this point forward you must specifically allow# particular features to be enabled - so if something's not working as# you might expect, make sure that you have specifically enabled it# below.### 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 "E:\apache-tomcat-7.0.50\webapps\ROOT"<Directory "E:\apache-tomcat-7.0.50\webapps\ROOT">## 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# /docs/2.4/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:# AllowOverride FileInfo AuthConfig Limit#AllowOverride None## Controls who can get stuff from this server.#Require all granted</Directory>## DirectoryIndex: sets the file that Apache will serve if a directory# is requested.#<IfModule dir_module>DirectoryIndex index.html index.php index.htm index.jsp</IfModule>## The following lines prevent .htaccess and .htpasswd files from being# viewed by Web clients.#<Files ".ht*">Require all denied</Files>## ErrorLog: The location of the error log file.# If you do not specify an ErrorLog directive within a <VirtualHost># container, error messages relating to that virtual host will be# logged here. If you *do* define an error logfile for a <VirtualHost># container, that host's errors will be logged there and not here.#ErrorLog "logs/error.log"## LogLevel: Control the number of messages logged to the error_log.# Possible values include: debug, info, notice, warn, error, crit,# alert, emerg.#LogLevel warn<IfModule log_config_module>## The following directives define some format nicknames for use with# a CustomLog directive (see below).#LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedLogFormat "%h %l %u %t \"%r\" %>s %b" common<IfModule logio_module># You need to enable mod_logio.c to use %I and %OLogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule>## The location and format of the access logfile (Common Logfile Format).# If you do not define any access logfiles within a <VirtualHost># container, they will be logged here. Contrariwise, if you *do*# define per-<VirtualHost> access logfiles, transactions will be# logged therein and *not* in this file.#CustomLog "logs/access.log" common## If you prefer a logfile with access, agent, and referer information# (Combined Logfile Format) you can use the following directive.##CustomLog "logs/access.log" combined</IfModule><IfModule alias_module>## Redirect: Allows you to tell clients about documents that used to# exist in your server's namespace, but do not anymore. The client# will make a new request for the document at its new location.# Example:# Redirect permanent /foo /bar## Alias: Maps web paths into filesystem paths and is used to# access content that does not live under the DocumentRoot.# Example:# Alias /webpath /full/filesystem/path## If you include a trailing / on /webpath then the server will# require it to be present in the URL. You will also likely# need to provide a <Directory> section to allow access to# the filesystem path.## ScriptAlias: This controls which directories contain server scripts.# ScriptAliases are essentially the same as Aliases, except that# documents in the target directory are treated as applications and# run by the server when requested rather than as documents sent to the# client. The same rules about trailing "/" apply to ScriptAlias# directives as to Alias.#ScriptAlias /cgi-bin/ "D:/apache-httpd/cgi-bin/"</IfModule><IfModule cgid_module>## ScriptSock: On threaded servers, designate the path to the UNIX# socket used to communicate with the CGI daemon of mod_cgid.##Scriptsock cgisock</IfModule>## "D:/apache-httpd/cgi-bin" should be changed to whatever your ScriptAliased# CGI directory exists, if you have that configured.#<Directory "D:/apache-httpd/cgi-bin">AllowOverride NoneOptions NoneRequire all granted</Directory><IfModule mime_module>## TypesConfig points to the file containing the list of mappings from# filename extension to MIME-type.#TypesConfig conf/mime.types## AddType allows you to add to or override the MIME configuration# file specified in TypesConfig for specific file types.##AddType application/x-gzip .tgz## AddEncoding allows you to have certain browsers uncompress# information on the fly. Note: Not all browsers support this.##AddEncoding x-compress .Z#AddEncoding x-gzip .gz .tgz## If the AddEncoding directives above are commented-out, then you# probably should define those extensions to indicate media types:#AddType application/x-compress .ZAddType application/x-gzip .gz .tgz## AddHandler allows you to map certain file extensions to "handlers":# actions unrelated to filetype. These can be either built into the server# or added with the Action directive (see below)## To use CGI scripts outside of ScriptAliased directories:# (You will also need to add "ExecCGI" to the "Options" directive.)##AddHandler cgi-script .cgi# For type maps (negotiated resources):#AddHandler type-map var## Filters allow you to process content before it is sent to the client.## To parse .shtml files for server-side includes (SSI):# (You will also need to add "Includes" to the "Options" directive.)##AddType text/html .shtml#AddOutputFilter INCLUDES .shtml</IfModule>## The mod_mime_magic module allows the server to use various hints from the # contents of the file itself to determine its type. The MIMEMagicFile# directive tells the module where the hint definitions are located.##MIMEMagicFile conf/magic## Customizable error responses come in three flavors:# 1) plain text 2) local redirects 3) external redirects## Some examples:#ErrorDocument 500 "The server made a boo boo."#ErrorDocument 404 /missing.html#ErrorDocument 404 "/cgi-bin/missing_handler.pl"#ErrorDocument 402 /subscription_info.html### MaxRanges: Maximum number of Ranges in a request before# returning the entire resource, or one of the special# values 'default', 'none' or 'unlimited'.# Default setting is to accept 200 Ranges.#MaxRanges unlimited## EnableMMAP and EnableSendfile: On systems that support it,# memory-mapping or the sendfile syscall may be used to deliver# files. This usually improves server performance, but must# be turned off when serving from networked-mounted# filesystems or if support for these functions is otherwise# broken on your system.# Defaults: EnableMMAP On, EnableSendfile Off##EnableMMAP off#EnableSendfile on# Supplemental configuration## The configuration files in the conf/extra/ directory can be# included to add extra features or to modify the default configuration of # the server, or you may simply copy their contents here and change as # necessary.# Server-pool management (MPM specific)#Include conf/extra/httpd-mpm.conf# Multi-language error messages#Include conf/extra/httpd-multilang-errordoc.conf# Fancy directory listings#Include conf/extra/httpd-autoindex.conf# Language settings#Include conf/extra/httpd-languages.conf# User home directories#Include conf/extra/httpd-userdir.conf# Real-time info on requests and configuration#Include conf/extra/httpd-info.conf# Virtual hosts#Include conf/extra/httpd-vhosts.conf# Local access to the Apache HTTP Server Manual#Include conf/extra/httpd-manual.conf# Distributed authoring and versioning (WebDAV)#Include conf/extra/httpd-dav.conf# Various default settings#Include conf/extra/httpd-default.conf# Configure mod_proxy_html to understand HTML4/XHTML1<IfModule proxy_html_module>Include conf/extra/proxy-html.conf</IfModule># Secure (SSL/TLS) connections#Include conf/extra/httpd-ssl.conf## Note: The following must must be present to support# starting without SSL on platforms with no /dev/random equivalent# but a statically compiled-in mod_ssl.#<IfModule ssl_module>SSLRandomSeed startup builtinSSLRandomSeed connect builtin</IfModule>完成配置后,启动Apache 2.4,在 "E:\apache-tomcat-7.0.50\webapps\ROOT" 添加静态页⾯ index.html。
Tomcat 6在Linux上的安装配置

touch /var/lock/subsys/local
export JAVA_HOME=/usr/java/jdk1.6.0_16
/usr/local/apache-tomcat-6.0.26/bin/startup.sh
#这个是我的目录的
这样在系统重启后就可以自动启动Tomcat.
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-6.0.16/temp
Using JRE_HOME: /usr/local/jdk1.6.0_20
五、使用“ps -ef |grep tomcat”可以显示tomcat已启动
【或者在bin下执行./startup.sh】
我的电脑上会出现如下内容:
Using CATALINA_BASE: /usr/local/apache-tomcat-6.0.16
Using CATALINA_HOME: /usr/local/apache-tomcat-6.0.16
export TOMCAT_HOME="/usr/local/apach-tomcat-6.0.16"
保存退出
# source /etc/profile //让当前配置立即生效
四、启动tomcat服务器
$ /usr/local/apach-tomcat-6.0.16/bin/startup.sh
点击左侧的 download的一个版本,我选择的是 tomcat6.x,你可以根据自己的实际情况进行选择安装,点击超连接,选择 Binary Distributions 下的tar.gz (pgp, md5) 压缩包,进行下载
二、下载到本地后,进行解压
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
环境:操作系统均为:CentOS 5.1Apache2.X服务器一台:IP地址192.168.232.4;安装路径/usr/local/apache;Tomcat6服务器一台:IP地址192.168.232.5;安装路径/usr/local/tomcat;Tomcat6服务器一台:IP地址192.168.232.6;安装路径/usr/local/tomcat;配置:Apache安装:#./configure --prefix=/usr/local/apache --enable-modules=so--enable-mods-shared=all --enable-proxy --enable-proxy-connect--enable-proxy-ftp --enable-proxy-http --enable-proxy-ajp--enable-proxy-balancer --enable-rewrite注释:激活tomcat集群需要的enable-proxy,enable-proxy-http,enable-proxy-connect,enable-proxy-ajp和enable-proxy-balancer,其中proxy-ajp和proxy-balancer必须依赖proxy,如果是自定义的编译除了以上几个必须的模块外,mod_status也要编译进去,切记。
enable-proxy-ftp可以不编译。
#make;make install制作Apache启动项:#cp support/apachectl /etc/rc.d/init.d/httpd#vi /etc/rc.d/init.d/httpd添加以下内容:(包括#号)# Startup script for the Apache Web Server# chkconfig: 2345 85 15# description: Apache is a World Wide Web server .It is used to server# HTML files and CGI.# processname: httpd# pidfile: /usr/local/apache/log/httpd.pid# config: /usr/local/apache/conf/httpd.conf增加服务项#chkconfig --add httpd#chmod 755 /etc/rc.d/init.d/httpd#chkconfig --level 345 httpd onJDK安装:#chmod a+x jdk-6u4-linux-i586-rpm.bin#./jdk-6u4-linux-i586-rpm.binJAVA环境变量设置:#vi /etc/profile在文件最后添加以下内容:JAVA_HOME=/usr/java/jdk1.6.0_04CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jarPATH=$JAVA_HOME/bin:$PATHCATALINA_HOME=/usr/local/tomcatexport JAVA_HOME CLASSPATH PATH CATALINA_HOME执行如下命令使环境变量生效:source /etc/profile测试配置是否成功:java –versionTomcat安装:#wget[url]/tomcat/tomcat-6/v6.0.16/bin/apache-to mcat-6.0.16.tar.gz[/url]#tar zxvf apache-tomcat-6.0.16.tar.gz#mv apache-tomcat-6.0.16 /usr/local/tomcatTomcat随机启动:#vi /etc/rc.local添加以下内容:/usr/local/tomcat/bin/startup.shtomcat6配置文件server.xml:把<!-- You should set jvmRoute to support load-balancing via AJP ie :<Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm1">--><Engine name="Catalina" defaultHost="localhost">改成<!-- You should set jvmRoute to support load-balancing via AJP ie :--><Engine name="Standalone" defaultHost="localhost" jvmRoute="tomcatX"> <!--<Engine name="Catalina" defaultHost="localhost">-->说明:第一台tomcat就把jvmRoute="tomcat1"第二台tomcat就把jvmRoute="tomcat2"把<!--<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>-->去掉注释变为<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>***群集详细配置***<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="8"><Manager className="org.apache.catalina.ha.session.DeltaManager" expireSessionsOnShutdown="false"notifyListenersOnReplication="true"/><Channel className="org.apache.catalina.tribes.group.GroupChannel"> <MembershipclassName="org.apache.catalina.tribes.membership.McastService"address="228.0.0.4"port="45564"frequency="500"dropTime="3000"/><Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver" address="auto"port="4000"autoBind="100"selectorTimeout="5000"maxThreads="6"/><SenderclassName="org.apache.catalina.tribes.transport.ReplicationTransmitter"><TransportclassName="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/> </Sender><InterceptorclassName="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector "/><InterceptorclassName="org.apache.catalina.tribes.group.interceptors.MessageDispatch1 5Interceptor"/></Channel><Valve className="org.apache.catalina.ha.tcp.ReplicationValve"filter=""/><Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/><Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer" tempDir="/tmp/war-temp/"deployDir="/tmp/war-deploy/"watchDir="/tmp/war-listen/"watchEnabled="false"/><ClusterListenerclassName="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListen er"/><ClusterListenerclassName="org.apache.catalina.ha.session.ClusterSessionListener"/></Cluster>配置应用的web.xml:在每个webapps应用中,修改配置文件web.xml文件添加元素<distributable/> 在web.xml文件中<web-app>元素下增加以下内容:<!--此应用将与群集服务器复制Session--><distributable/>具体修改如下:修改前:<?xml version="1.0" encoding="ISO-8859-1"?><web-app xmlns="[url]/xml/ns/javaee[/url]"xmlns:xsi="/2001/XMLSchema-instance"xsi:schemaLocation="/xml/ns/javaee[url]/xml/ns/javaee/web-app_2_5.xsd[/url]"version="2.5"></web-app>修改后:<?xml version="1.0" encoding="ISO-8859-1"?><web-app xmlns="[url]/xml/ns/javaee[/url]"xmlns:xsi="/2001/XMLSchema-instance"xsi:schemaLocation="/xml/ns/javaee[url]/xml/ns/javaee/web-app_2_5.xsd[/url]"version="2.5"><!--此应用将与群集服务器复制Session--><distributable/></web-app>配置apache的ajp负载均衡功能:确保将以下Module的注释去掉LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_connect_module modules/mod_proxy_connect.so LoadModule proxy_ftp_module modules/mod_proxy_ftp.soLoadModule proxy_http_module modules/mod_proxy_http.soLoadModule proxy_ajp_module modules/mod_proxy_ajp.soLoadModule proxy_balancer_module modules/mod_proxy_balancer.so LoadModule status_module modules/mod_status.so增加以下内容:# Proxypass ConfigInclude conf/extra/httpd-modproxy.conf建立文件httpd-modproxy.conf输入内容:<Location /server-status>SetHandler server-statusOrder Deny,AllowDeny from allAllow from all</Location><Location /balancer-manager>SetHandler balancer-managerOrder Deny,AllowDeny from allAllow from all</Location>ProxyRequests OffProxyPass / balancer://tomcatcluster stickysession=jsessionid nofailover=On<Proxy balancer://tomcatcluster>BalancerMember [url]http://192.168.232.5:8080[/url] loadfactor=1 BalancerMember [url]http://192.168.232.6:8080[/url] loadfactor=2</Proxy>注释:ProxyRequests Off 表示启用反向代理,必须开启;ProxyPass为代理转发的Url,即将所有访问/的请求转发到群集balancer://tomcatcluster,这里为/即将所有访问/的请求转发到群集balancer://tomcatcluster的/test目录;BalancerMember为群集的成员,即群集服务器1或2,负载均衡服务器会根据均衡规则来将请求转发给BalancerMember;调试负载均衡集群系统:访问apache服务器的web服务:[url]http://192.168.232.4/balancer-manager[/url]如果显示负载均衡有关信息则说明成功了,接着可以访问[url]http://192.168.232.4/[/url]即访问到了tomcat的应用***必须先启动Tomcat服务再启动Apache服务!***参考文档:[url]/tomcat-6.0-doc/cluster-howto.html[/url][url]/tomcat-6.0-doc/balancer-howto.html[/url][url]/newsoft/ApacheMenual_CN_2.2new/mod/mod_p roxy.html[/url][url]/newsoft/ApacheMenual_CN_2.2new/mod/mod_ proxy_balancer.html[/url]。