tomcat + apache +jkmod 配置php,jsp共存

httpd.conf

##############################################################################配置php
LoadModule php5_module "C:/Appserv/PHP/php5apache2_2.dll"
AddType application/x-httpd-php .php3 .php
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .po .py .pl .hu
PHPIniDir "C:/Appserv/PHP"
##############################################################################配置php

####################################################################加载JK模块
LoadModule jk_module "C:/Appserv/Apache2.2/modules/mod_jk.so"
JkWorkersFile "C:/Appserv/tomcat7/conf/workers.properties"
JkLogFile "C:/Appserv/Apache2.2/logs/mod_jk.log"
####################################################################加载JK模块

<VirtualHost *:80>
ServerName 域名1
DocumentRoot "C:/Appserv/W1/"
DirectoryIndex index.php index.html index.htm
JkMount /* A1                              ##实验证明这里的jkmout会影响下面的host jkmount配置,貌似是全局?现在还搞不懂
JkUnMount /*.php A1  
JkUnMount /images/* A1

</VirtualHost>

<VirtualHost *:80>
ServerName 域名2
DocumentRoot "C:\Appserv\W2\"
DirectoryIndex index.html index.htm index.jsp
JkMount /* A2 
JkUnMount /*.php A2
</VirtualHost>

<VirtualHost *:80>
ServerName 域名3
DocumentRoot "C:\Appserv\W3\"
DirectoryIndex index.html index.htm index.jsp
JkMount /* A3 
JkUnMount /*.php A3
</VirtualHost>

server.xml

<Host name="域名1" appBase="C:\Appserv\W1\" unpackWARs="true" autoDeploy="true" >
<Context path="" docBase="C:\Appserv\W1\" reloadable="true" crossContext="true"/>

</Host>
<Host name="域名2" appBase="C:\Appserv\W2" unpackWARs="true" autoDeploy="true" >
<Context path="" docBase="C:\Appserv\W2" reloadable="true" crossContext="true"/>

</Host>
<Host name="域名3" appBase="C:\Appserv\W3" unpackWARs="true" autoDeploy="true" >
<Context path="" docBase="C:\Appserv\W3" reloadable="true" crossContext="true"/>

</Host>

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

workers.properties

workers.tomcat_home="C:\Appserv\tomcat7\" #让mod_jk模块知道Tomcat的安装路径

workers.java_home="C:\Appserv\jdk1.8.0_66" #让mod_jk模块知道jdk路径

ps=\
worker.list=A1,A2,A3

worker.A1.port=8009
worker.A1.host=域名1
worker.A1.type=ajp13
worker.A1.lbfactor=1

worker.A2.port=8009 #工作端口,若没占用则不用修改
worker.A2.host=域名2 #本机,若上面的Apache主机不为localhost,作相应修改
worker.A2.type=ajp13 #类型
worker.A2.lbfactor=1 #代理数,不用修改

worker.A3.port=8009 #工作端口,若没占用则不用修改
worker.A3.host=域名3 #本机,若上面的Apache主机不为localhost,作相应修改
worker.A3.type=ajp13 #类型
worker.A3.lbfactor=1 #代理数,不用修改

写在最后:index.php不能被默认,我的方法是写一个index.jsp跳转(如果在tomcat设置index.php为默认,php会不被解析)

上一篇:《HBase权威指南》一1.3 非关系型数据库系统Not-Only-SQL(简称NoSQL)


下一篇:在Ubuntu12.0.4下搭建TFTP服务器