1 安装 tomcat/apache
2 下载 jk.so, 具体版本请根据需要,不再多说
3 关键是配置
httpd.conf查看复制到剪切板打印
# 去掉这个前面的#,启用它
LoadModule rewrite_module modules/mod_rewrite.so
# 启用jk,同时配置参数
LoadModule jk_module modules/mod_jk.so
JkWorkersFile D:/Apache2.2/conf/workers.properties
JkLogFile d:/Apache2.2/logs/mod_jk.log
JkLogLevel info
#JkLogLevel debug
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkMount /servlet/* myloadbalancer
JkMount /*.jsp myloadbalancer
# 虚拟主机,这里模拟了 a.test.com 和 b.test.com 以及 a.tst.com/blog的调用
<VirtualHost _default_:80>
ServerAdmin yourmail@domain.com
DocumentRoot D:\Apache2.2\htdocs
ServerName all-sites
ErrorLog logs/all-sites-error.log
CustomLog logs/all-sites-access.log common
RewriteEngine On
# 下面三行实现动态解析
RewriteCond %{HTTP_HOST} ^[a-z0-9\-]+\.test\.com$
RewriteRule ^/(.*)$ /%{HTTP_HOST}/$1
RewriteRule ^/([a-z0-9\-]+)\.test\.com/?$ /index.jsp?u=$1 [L,PT]
RewriteRule ^/([a-z0-9\-]+)\.test\.com/blog(/(.*))?$ /blog.jsp?u=$1&$3 [L,PT]
<Directory "D:\Apache2.2\htdocs">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
# 去掉这个前面的#,启用它
LoadModule rewrite_module modules/mod_rewrite.so
# 启用jk,同时配置参数
LoadModule jk_module modules/mod_jk.so
JkWorkersFile D:/Apache2.2/conf/workers.properties
JkLogFile d:/Apache2.2/logs/mod_jk.log
JkLogLevel info
#JkLogLevel debug
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkMount /servlet/* myloadbalancer
JkMount /*.jsp myloadbalancer
# 虚拟主机,这里模拟了 a.test.com 和 b.test.com 以及 a.tst.com/blog的调用
<VirtualHost _default_:80>
ServerAdmin yourmail@domain.com
DocumentRoot D:\Apache2.2\htdocs
ServerName all-sites
ErrorLog logs/all-sites-error.log
CustomLog logs/all-sites-access.log common
RewriteEngine On
# 下面三行实现动态解析
RewriteCond %{HTTP_HOST} ^[a-z0-9\-]+\.test\.com$
RewriteRule ^/(.*)$ /%{HTTP_HOST}/$1
RewriteRule ^/([a-z0-9\-]+)\.test\.com/?$ /index.jsp?u=$1 [L,PT]
RewriteRule ^/([a-z0-9\-]+)\.test\.com/blog(/(.*))?$ /blog.jsp?u=$1&$3 [L,PT]
<Directory "D:\Apache2.2\htdocs">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>workers.properties查看复制到剪切板打印
worker.list=myloadbalancer
worker.tomcat1.type=ajp13
worker.tomcat1.host=localhost
worker.tomcat1.port=8009
worker.tomcat1.lbfactor=1
worker.myloadbalancer.type=lb
worker.myloadbalancer.balance_workers=tomcat1
worker.status.type=status
worker.list=myloadbalancer
worker.tomcat1.type=ajp13
worker.tomcat1.host=localhost
worker.tomcat1.port=8009
worker.tomcat1.lbfactor=1
worker.myloadbalancer.type=lb
worker.myloadbalancer.balance_workers=tomcat1
worker.status.type=status server.xml
去掉前后的<!-- 和 -->启用 8009端口查看复制到剪切板打印
<Connector port="8009"
..