Notes on Tomcat6 Apache2 Ubuntu Server integration

Source: Internet
Author: User

By default, Tomcat 6 Apache2 installed on Ubuntu Server can run smoothly independently. to rewrite the URL, You need to integrate the two software.

Since it was installed by default in the system, many problems have been encountered when setting the server, including environment variables. Therefore, you must not be lazy in future installation ......

The premise of integration is that environment variables are set. Tomcat 6 works on port 8080 and Apache2 works on port 80.

Many tutorials on the network are about the JK module. After multiple attempts, the system still fails. The source code of JSP is read in Apache and the JSP is not handed over to Tomcat for execution. The integration fails, the reason may be related to the version and the existing installation method, because you are not familiar with Linux-related content and give up this method ......

There are two other methods that are less talked about, but relatively simple. The Mod, MOD_PROXY and MOD_AJP are used. The two methods are similar. The latter and JK use the same content. I used the former, all required modules can be installed with Apt-get. The configuration files of Apache2 contain these modules, so no special settings are required.

Then, set the virtual host in the default virtual host configuration file.

<VirtualHost www.linuxidc.com>
ServerName www.linuxidc.com
ServerAdmin admin@linuxidc.com
DocumentRoot/var/lib/tomcat6/webapps/ROOT
DirectoryIndex index.html index. jsp

ProxyPass/js!
ProxyPass/images!
ProxyPass/css!
ProxyPass/phpmyadmin!
ProxyPass/http: // 127.0.0.1: 8080/

<Directory/var/lib/tomcat6/webapps/ROOT>
Options Indexes FollowSymlinks
AllowOverride None
Order deny, allow
Allow from all
</Directory>
</VirtualHost>

ProxyPass is the key here. I wrote five articles. The first four articles aim to exclude these directories so that Apache can process them (which is more efficient than Tomcat and has a php program ), the last line is to make all the files under the directory switch to Tomcat processing on port 8080, which is actually mainly JSP files!

In addition, you must configure Tomcat server. xml.
Site

The principle is to establish a proxy mechanism to redirect access to Apache to Tomcat, so that a simple integration is completed. Compared with JK, the operation is simple and only applicable to Apache 2.2 and later versions, it is said that the stability is not as good as JK, that is, it is not mature enough. It may have passed and remains to be verified ......

Although I have estimated that JK cannot be used due to my server configuration problems, it is not recommended to use JK in Apache2 for some networks, but the related content is also small.

If Tomcat is as powerful as Apache, you don't have to worry about it ......
 

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.