Install and configure Apache HTTP Server and Tomcat

Install Apache HTTP Server

  1. Download the Windows binary distribution (.msi file) from http://archive.apache.org/dist/httpd/binaries/win32/.

  2. Run the MSI file that you downloaded.

  3. By default, the Apache HTTP Server is installed on port 80. If some other server is using port 80, you must change the port on which Apache listens for requests in the <apache-httpd- install>\conf\httpd.conf file. Search for the directive Listen in the configuration file and change the port number by changing this directive to <new-port-num>.

  4. Ensure that the Apache HTTP server is working correctly. To do so, enter the URL for the Apache server (http://<hostname>:<port-number>) in a Web browser. The server should display a page in the browser that says, “It Works!”.

Download sample workers.properties

Download sample workers.properties from this page, place it in the <apache-httpd -install>\conf folder. Now, modify the following variables:
  • workers.tomcat_home: Set to the Tomcat installation directory.

  • workers.java_home: Set to the JDK path.

Download the mod_jk module
  1. Download the mod_jk module for Apache from https://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.23/. This module exists as mod_jk-apache-2.2.4.so.

  2. Place the module in the <apache-httpd-install>\modules\ folder.

Modify the <apache httpd install>\conf\httpd.conf file

  1. Add the mod_jk module by appending the following line of text to the <apache-httpd -install>\conf\httpd.conf file: LoadModule jk_module modules/mod_jk-apache-2.2.4.so

  2. Using the JkMount command, add the context names that you want to direct to Tomcat: JkMount /robohelp/* ajp13 JkMount /th robohelp ajp13

Enable Apache auto-configure

  1. In the server.xml for Tomcat (<tomcat-install-folder>\conf\server.xml), enable Apache auto-configure. Tomcat automatically generates the files required for using mod_jk with an Apache HTTPS Web server.
    <Engine> 
    ...... 
    <Host> 
    ................ 
    </Host> 
    <Listener className="org.apache.jk.config.ApacheConfig" 
    	 modJk=<apache-install-folder>\modules\<mod_jk_module> 
    	 workersConfig=<apache install folder>\conf\workers.properties /> 
    </Engine>

    modJK and workersConfig must have appropriate values. For example:

    <Listener className="org.apache.jk.config.ApacheConfig" 
              modJk="C:\Program Files\Apache Software Foundation\Apache2.2\modules\mod_jk-apache-2.2.4.so" 
              workersConfig="C:\Program Files\Apache Software Foundation\Apache2.2\conf\workers.properties" />
  2. Stop the Apache HTTP Web server if it is running.

  3. Restart Tomcat. The <tomcat-install-folder>\conf\auto\mod_jk.conf file is generated. This file decides which URLs Apache passes to Tomcat.

Note: In mod_jk.conf, Tomcat creates a <VirtualHost> XML tag whose argument is the name of the <Host> tag just before the <Listener>(for modJK) tag in server.xml of Tomcat. Change the value of the name attribute of the <Host> tag to the server name.
Include the auto-generated file in Apache’s httpd.conf file

Add “Include <tomcat-install-folder>\conf\auto\mod_jk.conf” at the start of the httpd.conf file.

Restart the Apache HTTP server

If the Apache HTTP server service does not start due to some error, do the following:
  1. Run the command prompt.

  2. Go to <apache-install-folder>\bin.

  3. Run httpd.exe to check for errors.

Enable UTF-8 encoded URLs

Modify <tomcat-install-folder>\conf\server.xmland enable UTF-8 encoded URLs in all connector tags:
.............. 
 <Connector port="9090" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" /> 
............ 
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8" /> 
............

Set up Tomcat for HTTPS

  1. At the command prompt, change to the [JAVA_HOME]\bin directory.

    Note: The JAVA_HOME environment variable usually points to the Java installation directory.
  2. Run the following command: keytool -genkeypair -alias tomcat -keyalg RSA -keystore key1 -validity 30

    A new keystore file is created in the home directory of the user who runs the command. To specify a different location or file name, modify the command to add the -keystore parameter followed by the complete path of the keystore file. You will also need to specify this new path in the server.xml configuration file, as described in Step 6.

  3. Enter the keystore password.

  4. Enter the appropriate values when prompted for your personal and organization information.

  5. When prompted, enter the Tomcat key password.

  6. Modify the server.xml file for your Tomcat server and add the following text, replacing the bold text with appropriate values for your system:

    <Connector port=[port number] protocol="HTTP/1.1" SSLEnabled="true" 
    maxThreads="150" scheme="https" secure="true" 
    clientAuth="false" 
    strategy="ms" 
    	address="${jboss.bind.address}" 
    	keystoreFile="${jboss.server.home.dir}/conf/THE_KEYSTORE_NAME" 
    	keystorePass="PASSWORD_FOR_THE_KEYSTORE" 
    	truststoreFile="${jboss.server.home.dir}/conf/THE_KEYSTORE_NAME"               
    	truststorePass="PASSWORD_FOR_THE_KEYSTORE"               
    	sslProtocol="TLS"/>
  7. Restart Tomcat.