Integration of Apache and tomcat in Windows

Source: Internet
Author: User

In order to complete this task, I checked a lot of information on the Internet, either unclear, or the software version was too old and took a lot of detours. Here I take my actual operations as an example, let's talk about the integration process and hope to help you.

Preparations:

1. Apache 2.2.4
: Http://cztele1.skycn.com/down/apache_2.2.4-win32-x86-no_ssl.zip

2. Tomcat 6.0.16
: Http://apache.mirror.phpchina.co... e-tomcat-6.0.16.zip

3. JDK
: Http://cds.sun.com/is-bin/INTERS...
-Windows-i586-p.exe
If it is only an application, you can also choose to install JRE, Because JRE is relatively small :)

4 JK-1.2.26-httpd-2.2.4
: Http://www.apache.org/dist/tomca...
2.26-httpd-2.2.4.so
Note that the JK version must be the same as the apache version. If your version is different from mine, you can download it from the official website. There are multiple versions available for various operating systems. The download is applicable:
Http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/

Start installation:

The installation sequence of the software can be adjusted appropriately, but JDK (JRE) must be installed before Tomcat:

1. Install JDK (JRE)
By default, custom installation is supported. After the installation is complete, set your system environment variables as follows: My computer-> properties-> advanced
-> Environment variables (system variables and non-user variables are to be added here)

Java_home = D: \ Program Files \ Java \ jdk1.6.0 _ 07
Classpath =
.; % Java_home % \ Lib \ tools. jar; % java_home % \ Lib \ DT. jar;
Path =
% Java_home % \ bin

Note that the java_home path is changed to your actual installation path. The other two remain unchanged.

2. install Apache
Note that if your local machine has already installed IIS and occupies port 80, you can disable IIS, specify other ports for IIS, or specify other ports for Apache, set according to the actual situation. To install Apache, set the network
Domain and Server
Set the name to localhost and your email address (this must be set, otherwise Apache cannot be started ).
After the installation is complete, if Apache uses port 80, enter
Http: // localhost. If other ports such as 81 are used, enter http: // localhost: 81. Apache is displayed.
. Now that Apache is running, you can see its icon in the system tray. Double-click it to control the apache service. We also need to install Tomcat and JK below, so now select
Stop to stop the apache service.

3. install Tomcat
Decompress tomcat to D: \ Program Files \ Tomcat and set the environment variables:

Catalina_base = D: \ Program Files \ Tomcat
Catalina_home = D: \ Program
Files \ Tomcat
Classpath = % catalina_home % \ Lib \ servlet-api.jar

Run D: \ Program Files \ Tomcat \ bin \ Startup. BAT to start Tomcat. If the Tomcat page appears, the installation is successful.

4. Install JK

Copy mod_jk-1.2.26-httpd-2.2.4.so to D: \ Program Files \ apache2.2 \ modules.

Configure the server below:

1. Configure Tomcat
Find
Conf/server. xml file, add the following statement in the middle of

<Context Path = "" docbase = "E: \ wwwroot" reloadable = "true"
Crosscontext = "true"/>

Here, if path is not empty, the virtual directory is set, and the path value is the virtual directory name.

Find the conf/workers. properties file in the Tomcat directory and compare the text content below. If there are differences, modify the text below.

Workers. tomcat_home = D: \ Program Files \ Tomcat
# Let the mod_jk module know the location of Tomcat
Workers. java_home = D: \ Program Files \ Java \ jre1.6.0 _ 07
# Let the mod_jk module know the location of the JRE
PS = \
Worker. List = ajp13 # module version
Worker. ajp13.port = 8009
# Working port. Do not modify it if it is not occupied
Worker. ajp13.host = localhost
# Modify the local machine if the above Apache host is not localhost
Worker. ajp13.type = ajp13
# Type
Worker. ajp13.lbfactor = 1 # Number of proxies, no need to modify

If this file does not exist, it is created based on the above content. After any modifications to Tomcat settings are made, the system must be restarted to take effect.

2. Configure Apache
Open D: \ Program
Files \ apache2.2 \ conf httpd. conf. Add the following section at the end.CodeAnd save.

Loadmodule jk_module
Modules \ mod_jk-1.2.26-httpd-2.2.4.so
# The mod_jk file here is the file you downloaded
Jkworkersfile
"D: \ Program
Files \ Tomcat \ conf \ workers. properties"
# Specify the Tomcat Listener Configuration File address
Jklogfile
"D: \ Program Files \ Tomcat \ logs \ mod_jk2.log"
# Specify the log storage location
Jkloglevel info

# Set a VM

# If the VM is not a VM, comment out or delete the localhost> and the last .
serveradmin
localhost
DocumentRoot E: /wwwroot
"E:/wwwroot">
# path of your site project, which must be the same as the directory settings in Tomcat, it is said that the above two settings must be set at the same time to take effect. No difference has been made in the case of
servername
localhost
directoryindex index.html index.htm index. JSP
errorlog
logs/shsc-error_log.txt
customlog logs/shsc-access_log.txt common
jkmount
/servlet/* ajp13
# Let Apache support Servlet transfer, used for Tomcat parsing
jkmount /*. JSP ajp13
# Let Apache support JSP transmission for Tomcat parsing
jkmount /*. do ajp13
# enable Apache to support. do transfer for Tomcat parsing

# action comments at the beginning, which can be deleted. The configuration here is to configure the site by setting the virtual directory, re-specifying the servername and DocumentRoot paths. In fact, Apache configuration can be very flexible, or you can choose not to use the virtual directory, directly modify the default configuration of the site, use any text editing tool to search for items such as servername, DocumentRoot, and serveradmin, and then modify the configuration according to your actual situation. I suggest you try different configurations. This is a pleasant experience.
after all the modifications are completed, double-click the Apache icon in the system tray and click Start to start the apache service.
enter http: // localhost/in the address bar, respectively. If the result is the same as http: // localhost: 8080/, Apache and tomcat are successfully integrated.

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.