apache与Tomcat整合配置文档[windows].txt

1\下载的软件(可以从此网址下载得到http://www.apache.org/dist/)

apache_2.2.4-win32-x86-no_ssl.zip

apache-tomcat-6.0.18.zip

mod_jk-1.2.28-httpd-2.2.3.so(下载地址:http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/)

2\安装

a\pache_2.2.4-win32-x86-no_ssl端口号8089

b\apache-tomcat-6.0.18端口号8081

c\把mod_jk-1.2.28-httpd-2.2.3.socopy到apache的modules目录下面

d\在hosts文件中加入一行127.0.0.1webservice.test.com

e\并对apache与tomcat进行基本的设置

3\配置

假如站点目录是d:\www\ROOT,包括静态文件与动态文件

apache配置

两个文件:

httpd.confhttpd-vhosts.conf

1\httpd.conf

a\apache的基本配置

b\增加workers.properties文件保存在apache的conf目录下

内容如下

workers.tomcat_home=D:\Tomcat6.0#让mod_jk模块知道Tomcat的位置

workers.java_home=D:\Java\jdk1.6.0\jre#让mod_jk模块知道jre的位置

ps=\

worker.list=ajp13#模块版本

worker.ajp13.port=8009#工作端口,若没占用则不用修改

worker.ajp13.host=localhost#本机,若上面的Apache主机不为localhost,作相应修改

worker.ajp13.type=ajp13#类型

worker.ajp13.lbfactor=1#代理数,不用修改

c\在httpd.conf文件结尾加上如下代码

LoadModulejk_modulemodules\mod_jk-1.2.28-httpd-2.2.3.so

JkWorkersFile"D:\Tomcat6.0\conf\workers.properties"

JkLogFile"D:\Tomcat6.0\logs\mod_jk2.log"

JkLogLevelinfo

JkMount/*.jspajp13

#把JSPX程序映射到Jk连接器上

JkMount/*.jspxajp13

#把servlet程序映射到Jk连接器上

JkMount/servlet/*ajp13

JkMount/*.servletajp13

d\httpd-vhosts.conf配置如下

NameVirtualHost*:8089

<VirtualHost*:8089>

[email protected]

DocumentRoot"D:/www/ROOT"

ServerNamewebservice.test.com

ServerAliastest

ErrorLog"logs/dummy-host.localhost-error.log"

CustomLog"logs/dummy-host.localhost-access.log"common

</VirtualHost>

4\最后在ie中运行http://webservice.test.com:8089/index.jsp与http://webservice.test.com:8081/index.jsp显示相同的内容表示配置成功

配置多虚拟主机(侦听一个端口的情况下)

补充

Listen8089

apache基本配置

<Directory"D:/www">

#

#PossiblevaluesfortheOptionsdirectiveare"None","All",

#oranycombinationof:

#IndexesIncludesFollowSymLinksSymLinksifOwnerMatchExecCGIMultiViews

#

#Notethat"MultiViews"mustbenamed*explicitly*---"OptionsAll"

#doesn'tgiveittoyou.

#

#TheOptionsdirectiveisbothcomplicatedandimportant.Pleasesee

#http://httpd.apache.org/docs/2.2/mod/core.html#options

#formoreinformation.

#

OptionsIndexesFollowSymLinks

#

#AllowOverridecontrolswhatdirectivesmaybeplacedin.htaccessfiles.

#Itcanbe"All","None",oranycombinationofthekeywords:

#OptionsFileInfoAuthConfigLimit

#

AllowOverrideNone

#

#Controlswhocangetstufffromthisserver.

#

Orderallow,deny

Allowfromall

</Directory>

注意:"D:/www"如果有多个站点,把所有的站点放入到该目录,这里标明是否有权限访问该目录

#Virtualhosts

Includeconf/extra/httpd-vhosts.conf

把上面这行包括时来

httpd-vhosts.conf的基本配置,如下

NameVirtualHost*:8089

<VirtualHost*:8089>

[email protected]

DocumentRootd:/www/wabappone/ROOT

ServerNamewww.wabappone.com

ServerAliaswabappone

ErrorLog"logs/wabappone.localhost-error.log"

CustomLog"logs/wabappone.localhost-access.log"common

</VirtualHost>

<VirtualHost*:8089>

[email protected]

DocumentRootd:/www/wabapptwo/ROOT

ServerNamewww.wabapptwo.com

ServerAliaswabapptwo

ErrorLog"logs/wabapptwo.localhost-error.log"

CustomLog"logs/wabapptwo.localhost-access.log"common

</VirtualHost>

<VirtualHost*:8089>

[email protected]

DocumentRootd:/www/wabappthree/ROOT

ServerNamewww.wabappthree.com

ServerAliaswabappthree

ErrorLog"logs/wabappthree.localhost-error.log"

CustomLog"logs/wabappthree.localhost-access.log"common

</VirtualHost>

===============================================================

问题解决

解决apache的therequestedoperationhasfailed收藏

装了个最新版本的svn后。apache不能正常启动。提示therequestedoperationhasfailed。花了半天时间研究有点眉目了。运行-》cmd进入到apache的bin目录。输入httpd.exe-w-n"Apache"-kstart

会提示配置文件的具体那行出错。找起来就方便多了。注:命令里的"Apache"是系统服务里apache服务的名称。及时换成你的

==============================================================

=========================================

特别注意,如果要整合apache与Tomcat在一起,apache解析静态页,tomcat解析动态页,并且是同时配置多个虚拟站点,则要像如下这样配置

---------------------------

JkMount/*.jspajp13

#把JSPX程序映射到Jk连接器上

JkMount/*.jspxajp13

#把servlet程序映射到Jk连接器上

JkMount/servlet/*ajp13

JkMount/*.servletajp13

-------------------------

分别如下形式加到具体的虚拟主机下

<VirtualHost*:8089>

[email protected]

DocumentRootd:/www/wabappone/ROOT

ServerNamewww.wabappone.com

ServerAliaswabappone

ErrorLog"logs/wabappone.localhost-error.log"

CustomLog"logs/wabappone.localhost-access.log"common

JkMount/*.jspajp13

#把JSPX程序映射到Jk连接器上

JkMount/*.jspxajp13

#把servlet程序映射到Jk连接器上

JkMount/servlet/*ajp13

JkMount/*.servletajp13

</VirtualHost>

<VirtualHost*:8089>

[email protected]

DocumentRootd:/www/wabapptwo/ROOT

ServerNamewww.wabapptwo.com

ServerAliaswabapptwo

ErrorLog"logs/wabapptwo.localhost-error.log"

CustomLog"logs/wabapptwo.localhost-access.log"common

JkMount/*.jspajp13

#把JSPX程序映射到Jk连接器上

JkMount/*.jspxajp13

#把servlet程序映射到Jk连接器上

JkMount/servlet/*ajp13

JkMount/*.servletajp13

</VirtualHost>

<VirtualHost*:8089>

[email protected]

DocumentRootd:/www/wabappthree/ROOT

ServerNamewww.wabappthree.com

ServerAliaswabappthree

ErrorLog"logs/wabappthree.localhost-error.log"

CustomLog"logs/wabappthree.localhost-access.log"common

JkMount/*.jspajp13

#把JSPX程序映射到Jk连接器上

JkMount/*.jspxajp13

#把servlet程序映射到Jk连接器上

JkMount/servlet/*ajp13

JkMount/*.servletajp13

</VirtualHost>

=========================================

apache与tomcat在不同一台机器上的配置

apache同时侦听多个端口

tomcat同时侦听多个端口

apache的Rewrite设置

如果,需要用到rewrite的html静态功能,请在httpd.conf文件中,找到

#LoadModulerewrite_modulemodules/mod_rewrite.so

取消掉前面的#注释,使mod_rewrite.so模块生效并且把所有的

AllowOverrideNone

更改为

AllowOverrideAll

===================================================

tomcat配置只允许特定的IP访问的配置方式

===================================================

在context.xml文件中加上如下代码

<Valveclassname="org.apache.catalina.valves.RemoteAddrValve(RemoteHostValve主机名)"

allow="127.0.0.1(允许访问的ip)"deny="192.168.1.1(拒绝访问的ip)"/>

org.apache.catalina.valves.RemoteAddrValve过滤的是ip地址

org.apache.catalina.valves.RemoteHostValve过滤的是主机名

如果存在多主机,多ip需要过滤,以","分隔.

http://127.0.0.1:81/WServiceServer/services/InvokeProduct

相关推荐