Apache+tomcat Configuration Guide on the Windows platform

Source: Internet
Author: User
Tags win32 java web net domain tomcat server java se
This article mainly describes 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 the completion of a Web server with Apache as a 80 port, Tomcat as the Java Web Application container, both through a MOD_JK connection to provide services to the outside world. Now we start the configuration process:
1, download the Apache HTTP server
Download Address: http://httpd.apache.org, at the time of writing, HTTPD's server is currently the latest release of 2.2.11 (we call the 2.2 version), we chose the Windows platform for the binary version of the download, we'd better choose Win32 Binary including OpenSSL 0.9.8i (MSI Installer), because this version is just SSL, you may need to provide SSL functionality in the future, so it's a precaution.
2, the installation of Apache HTTP Server
The task of this step is very simple, for the Windows platform, you just follow the installation Wizard step-by-step to complete the installation task on it, in the process you can be asked to fill out some information, such as the server domain name (you can be based on your server actual domain name, if you are just testing, Did not apply for a domain name, you can fill out a random, admin email and so on. Remember the installation directory of your software during this process and we will use this directory in the next step. We will take a screenshot of each step of the installation process as follows:







3. Download and install JDK6
Download address: 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 order the next step to complete the task, the installation process to select the installation directory, we assume that the installation directory for d:/java/jdk1.6.
4, download Tomcat 6
Download Address: http://tomcat.apache.org/download-60.cgi, select the Windows platform Tomcat software, you can choose the Windows Service Installer version.
5. Install Tomcat 6
This process is also close to the fool type, here will be the Tomcat 6 installation process screenshot as follows:











6. Download and configure MOD_JK
Download Address: 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, it's important to note that you should have your Apache version to select the MOD_JK version. Once 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 Apache installation directory, and you will be in this directory (C:/Program Files/apache Software 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), where you find the content containing the LoadModule typeface, add a new loadmodule underneath the content, which is designed to add a new module function to Apache, which is MOD_JK, It is designed 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 properly, the MOD_JK module must know where the Tomcat server is being manipulated, and this content needs to be configured in another file, Now we'll name the file workers.properties, put the file in the same place as httpd.conf (you can 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 the existence of the file, so we need to open the httpd.conf file again, adding the following line below the line we just added LoadModule:
Jkworkersfile conf/workers.properties
OK, now that you've completed the configuration of the ways and parameters of Apache and Tomcat, the next thing you need to do is configure which Web application 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 httpd.conf configuration, find #include conf/extra/httpd-vhosts.conf, remove the # in front of this line, and 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 the following:
<directory/>
Options FollowSymLinks
AllowOverride None
</Directory>
The purpose is to configure the virtual host for Apache, and to specify a different directory as a directory for the Web site to generate an error that does not have access.
Then open C:/Program files/apache Software foundation/apache2.2/conf/extra/httpd-vhosts.conf, remove the contents of the virtual host part that is already configured inside, as follows:
<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 "Logs/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 "Logs/dummy-host2.ojava.net-error.log"
Customlog "Logs/dummy-host2.ojava.net-access.log" common
</VirtualHost>
Add our own configuration of the information, configuration content 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>
Here we have forwarded the request for access to the Www.ojava.net domain name website to tomcat for processing. At this point, if you need to configure the virtual host in Tomcat, you can continue to modify the Tomcat configuration file, if you do not need, so here, you have completed the configuration process. Congratulations, now restart Apache and Tomcat, you can test it, success. There are questions to welcome the exchange.

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.