Apache + Tomcat Configuration Guide on Windows

Source: Internet
Author: User
Tags net domain
This article describes how to build a web server for the Java platform on the Windows platform.
The software used throughout the process includes: Apache HTTP Server, JDK 6, Tomcat 6, and mod_jk. The goal is to complete the configuration of a Web server with port 80 from Apache and tomcat as a Java Web application container. The two services are provided externally through the mod_jk connection. Now let's start the configuration process:
1. Download Apache HTTP Server
: Http://httpd.apache.org, at the time of writing this article, the httpd server's current latest release version is 2.2.11 (we call it Version 2.2), we choose 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, and you may need to provide SSL functions in the future, so we are prepared here.
2. install Apache's HTTP Server
The task in this step is very simple. For Windows platforms, you only need to complete the installation task step by step according to the installation wizard. During the process, you can be asked to enter some information, for example, the domain name of the server (you can enter the domain name based on the actual domain name of your server, if you only perform the test and have not applied for a domain name, you can enter a domain name as needed ), administrator emails. Remember the installation directory of your software in this process. We will use this directory in the next step. Each step of the installation process is recorded as follows:







3. Download and install JDK 6
: Http://java.sun.com/javase/downloads? Intcmp = 1281, download Java SE Development Kit (JDK) 6 Update 11.
The process of installing JDK is very simple. You only need to go to the next step to complete the task. During the installation process, select the installation directory. Here we assume that the installation directory is D:/Java/jdk1.6.
4. Download Tomcat 6
: Http://atat.apache.org/download-60.cgi. select the Tomcat software for Windows platform. You can select the Windows Service installer version.
5. install Tomcat 6
The Installation Process of Tomcat 6 is almost dumb. Here, the installation process of Tomcat 6 is as follows:

6. Download and configure mod_jk
: Bytes. After you have the so file, the next task is to configure the so module to the Apache server.
First, copy the mod_jk-1.2.27-httpd-2.2.10.so to the modules directory in the installation directory of Apache, and you will see a lot of so files in this directory (C:/program files/Apache Software Foundation/apache2.2/modules. Open the Apache configuration file (C:/program files/Apache Software Foundation/apache2.2/CONF/httpd. conf), find the content containing the loadmodule, and add a new loadmodule below the content to add a new module function to Apache, this module is mod_jk, which aims 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
To work correctly, the mod_jk module must know where the Tomcat server is controlled by it, and this content needs to be configured in another file. Now we name this file workers. properties, put this file in httpd. conf is the same (of course you can place it wherever you want). The content of the file is 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 must tell mod_jk the existence of this file, so we need to open httpd again. CONF file, add the following line below the loadmodule line we just added:
Jkworkersfile CONF/workers. Properties
Now that you have configured the communication methods and parameters between APACHE and tomcat, You need to configure which web application needs to be transferred to Tomcat by Apache for processing, the following uses a VM as an example:
We add a new virtual host configuration for Apache. First, modify httpd. CONF configuration, find # include CONF/extra/httpd-vhosts.conf, remove the # Before this line, so that the configuration of this line takes effect. Then, find the following content in the configuration file:
<Directory/>
Options followsymlinks
AllowOverride none
Order deny, allow
Deny from all
</Directory>
Modify it to the following content:
<Directory/>
Options followsymlinks
AllowOverride none
</Directory>
The purpose is to configure a virtual host for Apache and specify another directory as the directory of the web site to generate an error with no access permission.
Then open C:/program files/Apache Software Foundation/apache2.2/CONF/extra/httpd-vhosts.conf, remove the contents of the configured virtual host, as shown below:
<Virtualhost *: 80>
Serveradmin webmaster@dummy-host.ojava.net
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 "log/dummy-host.ojava.net-error.log"
Customlog "logs/dummy-host.ojava.net-access.log" common
</Virtualhost>

<Virtualhost *: 80>
Serveradmin webmaster@dummy-host2.ojava.net
DocumentRoot "C:/program files/Apache Software Foundation/apache2.2/docs/dummy-host2.ojava.net"
Servername dummy-host2.ojava.net
Errorlog "log/dummy-host2.ojava.net-error.log"
Customlog "logs/dummy-host2.ojava.net-access.log" common
</Virtualhost>
Add our own configuration information. The configuration content is as follows:
<Virtualhost *: 80>
Serveradmin steven@ojava.net
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>
At this point, we have forwarded the access request to the www.ojava.net domain name website to Tomcat for processing. If you need to configure the virtual host in Tomcat, you can continue to modify the tomcat configuration file. If you do not need, you have completed the configuration process. Congratulations, restart Apache and tomcat now. You can test it. Is it successful? If you have any questions, please contact us.

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.