Apache+tomcat Configuration Guide on the Windows platform

Source: Internet
Author: User
Tags net domain java se

This article focuses on how to build a Web server process for the Java platform on the Windows platform.
The software used throughout the process includes: Apache HTTP server, JDK6, Tomcat 6, mod_jk. The goal is to configure a Web server with Apache as a 80 port, and Tomcat to serve as a Java Web Application container, both of which work through MOD_JK connections to provide services externally. Now let's start the configuration process:
1. Download Apache HTTP Server
: http://httpd.apache.org, when this article was written, HTTPD's current release of the server is 2.2.11 (we call version 2.2), we chose to download the binary version of the Windows platform, we'd better choose Win32 binary including OpenSSL 0.9.8i (MSI Installer), because this version is only SSL, you may need to provide SSL functionality in the future, so be prepared here.
2. Install Apache HTTP Server
The task of this step is very simple, for the Windows platform, you only need to follow the installation wizard step by step to complete the installation task can be, in the process you can be asked to fill in some information, such as the server domain name (you can be based on the actual domain name of your server to fill, if you just test, Did not apply for the domain name, you can fill in a random, the administrator's e-mail and so on. In this process, remember the installation directory of your software, we will use this directory in the next steps. We will record each step of this installation process as follows:





3. Download and install JDK6
: http://java.sun.com/javase/downloads/?intcmp=1281, download Java SE Development Kit (JDK) 6 Update 11.
The process of installing the JDK is very simple, you only need to complete the task in sequence, the installation process is careful to select the installation directory, we assume that the installation directory is d:\java\jdk1.6.
4. Download Tomcat 6
: http://tomcat.apache.org/download-60.cgi, select the Windows platform Tomcat software, you can choose the Windows Service Installer version.
5. Installing Tomcat 6
This process is also near the idiot type, here the Tomcat 6 installation process is as follows:




6. Download and configure MOD_JK
: Http://apache.mirror.phpchina.com/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.27/mod_ Jk-1.2.27-httpd-2.2.10.so, here you need to be aware that you should have more of your Apache version to choose the version of MOD_JK. Once you have the so file, the next task is to configure the so module in the Apache server.
First copy the mod_jk-1.2.27-httpd-2.2.10.so to the Apache installation directory in the modules directory where you will be in this directory (C:\Program Files\apache software foundation\ Apache2.2\modules) See a lot of so files. Then open the Apache configuration file (C:\Program Files\apache software foundation\apache2.2\conf\ httpd.conf), in which the content containing the LoadModule typeface is found, and a new loadmodule is added underneath the content to add a new module function to Apache, the module is MOD_JK, Its purpose is to enable Apache to collaborate with Tomcat. Add the following line below LoadModule:
LoadModule Jk_module modules/mod_jk-1.2.27-httpd-2.2.10.so
MOD_JK module to work correctly, you must know where the Tomcat server is being manipulated, and this content needs to be configured in another file. Now let's name the file workers.properties, put the file in the same place as httpd.conf (you can, of course, put it wherever you want), and the file will read as follows:
Ps=\
Worker.list=ojava
worker.ojava.port=8009
Worker.ojava.type=ajp13
Worker.ojava.host=localhost
Worker.ojava.lbfactor=1
With this configuration file, we have to tell Mod_jk that the file exists, so we need to open the httpd.conf file again and add the following line below the LoadModule line we just added:
Jkworkersfile conf/workers.properties
Well, now that you've finished configuring the communication and parameters for Apache and Tomcat, the next thing you need to do is configure which web app needs to be forwarded by Apache to Tomcat for processing, and we'll take the virtual host as an example:
We add new virtual host configuration for Apache, first modify the configuration of httpd.conf, find # include conf/extra/httpd-vhosts.conf, remove the line in front of it, let the configuration of this line take effect. We then found the following in the configuration file:
<directory/>
Options FollowSymLinks
AllowOverride None
Order Deny,allow
Deny from all
</Directory>
Modify it to read as follows:
<directory/>
Options FollowSymLinks
AllowOverride None
</Directory>
The purpose of this is to configure the virtual host for Apache, and to specify a different directory as the Web site's directory when there are no unauthorized access errors.
Then open the C:\Program files\apache software foundation\apache2.2\conf\extra\httpd-vhosts.conf and remove the contents of the virtual host part that is already configured as follows:
<virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot "C:/Program Files/apache software Foundation/apache2.2/docs/dummy-host.ojava.net"
ServerName dummy-host.ojava.net
Serveralias www.dummy-host.ojava.net
Errorlog "Logs/dummy-host.ojava.net-error.log"
Customlog "Logs/dummy-host.ojava.net-access.log" common
</VirtualHost>

<virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot "C:/Program Files/apache software Foundation/apache2.2/docs/dummy-host2.ojava.net"
ServerName dummy-host2.ojava.net
Errorlog "Logs/dummy-host2.ojava.net-error.log"
Customlog "Logs/dummy-host2.ojava.net-access.log" common
</VirtualHost>
To add our own configuration information, configure the following:
<virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot "E:/ojava/web_root"
ServerName www.ojava.net

Jkmount/* Ojava

Errorlog "Logs/www.ojava.net-error.log"
Customlog "Logs/www.ojava.net-access.log" common
</VirtualHost>
Here we have forwarded the request for access to the Www.ojava.net domain site to Tomcat for processing. If you need to configure the virtual host in Tomcat then you can continue to modify the Tomcat configuration file, and if you do not need it, you have completed the configuration process. Congratulations, now restart Apache and Tomcat, you can test, success? There are questions to welcome the exchange.

This article reprinted http://blog.csdn.net/stevencn76/archive/2008/12/22/3584925.aspx

Related Article

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.