Because many articles on the internet are outdated, and many Web sites around the article mess, see us dazzling, do not know who to listen to.
The next thing you need to do is follow me step-by-step. It is worth noting that, in order to test the effect, your domain resolution must be configured correctly, such as www.domain1.com, you need to add a record of the URL to set the value of your IP.
To achieve the goal: access to app1,www.domain2.com access App2 via www.domain1.com. Both are via port 80.
The tools you need:
1.apache2.2.14
Download Address: http://httpd.apache.org/
2.tomcat5.5
http://tomcat.apache.org/download-55.cgi[Select the core zip, that is, the uncompressed installation is not required
3.mod_jk
http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.28/
Because we Apache is 2.2, so choose mod_jk-1.2.28-httpd-2.2.3.so here, of course, when you read this article may not have been 2.2.3, it doesn't matter, as long as the same as Apache.
Install I will not say it, will not Google yourself.
Apcahe all the way to determine, port selection 80, other casually fill does not matter.
MOD_JK download after the modules to the Apache installation directory, in order to facilitate the back of my mod_jk renamed into a mod_jk.so.
Tomcat can be decompressed, if you flash past that means that you are not configured the environment variables correctly, as long as the environment variable correct decompression can run, the other is in utter nonsense.
The first thing I want to configure is Apache. Thought of as an example
Java code namevirtualhost *:80 <VirtualHost *:80> servername www.wibowibo.com serveralias wibowibo.com *.wibowibo.com documentroot "f:/program files/apache software foundation/tomcat 5.0/ Webapps/root ' directoryindex index.html index.htm index.jsp # This is the same as welcome-list, welcome page jkmount /servlet/* wibowibo # Allow Apache to support the delivery of the servlet for Tomcat resolution jkmount /*.jsp wibowibo jkmount /*. htm wibowibo jkmount /*.html wibowibo #让Apache支持对jsp传送, For Tomcat parsing jkmount /*.do wibowibo #让Apache支持对. Do transfer, for Tomcat parsing jkmount /* wibowibo #设置这个apache将所有请求都转发给tomcat解析 #这里要根据自己的实际情况配置, If you are considering performance needs to consult more detailed information, this article does not discuss </virtualhost> <Directory "F:/program files/apache software foundation/tomcat 5.0/webapps/root "> Options Indexes FollowSymLinks AllowOverride None order allow,deny Allow from all </Directory> <VirtualHost *:80> servername www.zjjgh.org documentroot "F:/apache-tomcat-5.5.27/apache-tomcat-5.5.27/webapps/zjjgh" DirectoryIndex index.html index.htm index.jsp jkmount /servlet/* zjjgh # Allow Apache to support the delivery of the servlet for Tomcat parsing jkmount /*.jsp zjjgh jkmount /*.htm zjjgh #让Apache支持对jsp传送 for Tomcat resolution jkmount /*.do zjjgh #让Apache支Hold pairs. Do transmission, for Tomcat resolution jkmount /* zjjgh </VirtualHost> < directory "F:/apache-tomcat-5.5.27/apache-tomcat-5.5.27/webapps/zjjgh" > Options Indexes FollowSymLinks allowoverride none Order allow,deny allow from all </Directory> loadmodule jk_module modules/mod_jk.so #此处mod_jk的文件为你下载的文件 jkworkersfile "f:/apache-tomcat-5.5.27/ Apache-tomcat-5.5.27/conf/workers.properties " #指定tomcat监听配置文件地址 jklogfile " f:/ Apache-tomcat-5.5.27/apache-tomcat-5.5.27/logs/mod_jk2.log " #指定日志存放位置 Jkloglevel info
Java code <directory "F:/apache-tomcat-5.5.27/apache-tomcat-5.5.27/webapps/zjjgh" > Options Indexes followsymlink S allowoverride None order Allow,deny allow to all </Directory> this block is mainly declarative permission, otherwise you will be able to return an error in your browser. On ' t have permission something. In short this can not be less, and a documentroot corresponds to a directory
ServerName www.zjjgh.org
After the Servename is configured, the Tomcat Server.xml also needs to add the corresponding host.
Java code Note the case. Don't write host, or Tomcat will not start. Here's the name to correspond to ServerName, Docbase also to be consistent, this can be in any path, my two paths are placed in two Tomcat WebApps "be careful not to misunderstand, so we just need to start a tomcat on it, That's Workers.properties's tomcat. "As long as you have a path under which you can run the Java EE Project, of course, only a static HTML will do."
Next up is workers.properties.
This copy on the line, in Tomcat's Conf create a, inside the content of Java code workers.tomcat_home=f:/apache-tomcat-5.5.27/apache-tomcat-5.5.27 #让mod_ The JK module knows the location of Tomcat Workers.java_home=d:/java/jdk1.5.0_16/jre #让mod_jk模块知道jre的位置 ps=/Worker.list=zjjgh,wibowibo #模块版本 worker.zjjgh.port=9009 #工作端口, if not occupied then do not modify the worker.zjjgh.host=www.zjjgh.org #本机, if the above Apache host is not localhost, make corresponding changes Worker.zjjgh.type=ajp13 #类型 worker.zjjgh.lbfactor=1 #代理数, do not modify the worker.wibowibo.port=9009 #工作端口, if not occupied without modification worker.wi Bowibo.host=www.wibowibo.com #本机, if the above Apache host is not localhost, make the corresponding modification worker.wibowibo.type=ajp13 #类型 Worker.wibowibo.lbfactor=1 #代理数, no change.
Change the path to your own, and port is the same. The default is 8009, I changed to 9009, in Tomcat's server.xml there is a line of Java code <!--Define a AJP 1.3 Connector on port 8009--> <connector Port= "8009" enablelookups= "false" redirectport= "8443" protocol= "ajp/1.3"/> is consistent with this.
All right, start looking, start Tomcat first. The Tomcat set in the Workers.properites. Then start Apache, and enter the check separately. If the exception is, you can resolve the problem by looking at the Mod_jk.log under the Error.log and Tomcat logs directories under the Apache installation directory.