Integrate Tomcat and Apache

Source: Internet
Author: User

This is my first time writingArticleIt may also be the last time I wrote: :), Because I rarely write, I don't have time, but because of my painful experience and my sympathy (^_^ ), I don't want others to make the same mistakes. Okay, let's talk a little about it.
1. Download JK2. This plug-in is used to integrate Apache and other servers (IIS and tomcat are listed here). Without it, we can play with nothing. : Bytes.
2. JK2 is the latest version. JK was available in the past. JK2 is more powerful than JK. How can it be powerful? It seems that JNI and other things are supported. I have not studied it deeply and cannot use it now. Anyway, you only need to know That JK2 is good and powerful. JK2 supports integration of Apache of all versions and tomcat of all versions.
3. create workers2.properties under Apache conf (this name must be used, otherwise, even in httpd. jkset config. file CONF/workers. properties is not easy to use. If this name is used, this command is redundant ), it specifies the path and file that Apache forwards to Tomcat for running. For example:
[Channel. Socket: localhost: 8009]
Port = 8009
Host = 127.0.0.1

[Ajp13: localhost: 8009]
Channel = channel. Socket: localhost: 8009

[URI:/examples /*. JSP] # examples represents a virtual path in Tomcat. You can write any virtual path, and each virtual path can match any extension that can be forwarded to Tomcat.
[URI:/task4/*. jsp] # Another virtual path that instructs Apache to forward the JSP file of Task 4 Project to Tomcat for running.
Worker = ajp13: localhost: 8009 # I do not know what to use
4. Add the following at the end of Apache CONF/httpd. conf:
Loadmodule jk2_module "modules/mod_jk2.so", the path separator here can be // and/, no effect. The purpose of this statement is to load the module File of JK2.
5. Copy the JK2 file mod_jk2.so to the modules of Apache.

Note:
1. Tomcat listens to other servers integrated with port 8009 by default.
2. Sequence of starting Tomcat and Apache: start Tomcat first, and then start Apache after it is started. Otherwise, an internal error is returned.
3. JK2 is more powerful than JK.
4. How can I prove that the integration is successful?
If the same page is moved, one write port (Tomcat) and one non-write port (APACHE) can run normally, proving that the operation is successful.
5. The default port of Apache is 80.

Note: The practice mentioned in this article is also made in a document in csdn. However, it does not mention how to add multiple virtual paths, and many details are not clear, after a lot of hard work, I had to work on and off for two days and finally got it done. The funny thing was that at first I did it and it was not easy to use, but then I suddenly used it and fainted.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.