Wiki

Installing Tomcat 6 with Java 6 and Apache 2.2 on Windows Server 2003 x64

This article is a guide for installing and configuring Apache and Tomcat onto a Window 2003 Server running x64. At Anchor we always deploy Apache in front of Tomcat on dedicated and Virtual Private Servers for improved security and reliability. Best practice also suggests that Tomcat should only be used to serve up dynamic content with all static content coming from an httpd server (eg Apache or IIS).

Software versions being used in this article

Installing the software

Apache HTTPD

Java JDK

Apache Tomcat

Mod JK

Copy mod_jk-apache-2.2.27.so into c:/apache/httpd/apache/modules directory and rename it mod_jk.so

Testing the new software works

Apache HTTPD

If you don't get this page check:

Apache Tomcat

Making Mod JK work

A few basic steps for making Mod JK work with Apache, this part of the configuration is not very well documented on the Apache website.

If you haven't already

  1. Copy mod_jk-apache-2.2.27.so into c:/apache/httpd/apache/modules directory and rename it mod_jk.so

  2. Edit Tomcat6's server.xml file and add these lines:
    • Just below the line:
      <Server port="8005" shutdown="SHUTDOWN" debug="0"> 
      Add the following:
      <Listener className="org.apache.jk.config.ApacheConfig" modJk="c:/apache/httpd/modules/mod_jk.so" 
      workersConfig="c:/apache/tomcat/conf/jk/workers.properties" />
      And just below the line:
      <Host name="localhost" appBase="webapps" unpackWARs="true"
      autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
      Add the following line:
      <Listener className="org.apache.jk.config.ApacheConfig" append="true"
      forwardAll="false" modJk="c:/apache/httpd/modules/mod_jk.so" /> 
  3. Save the changes made to server.xml and restart the Tomcat service.
    • Wait a few seconds, and then check to see if there is a file called mod_jk.conf in tomcat/conf/auto directory.

    • If there is not, you did something wrong!
  4. Create the workers.properties file in tomcat/conf/jk, with the following lines to it:

    • # BEGIN workers.properties
      # Definition for Ajp13 worker
      worker.list=ajp13
      worker.ajp13.port=8009
      worker.ajp13.host=localhost
      worker.ajp13.type=ajp13
      # END workers.properties
  5. Restart Tomcat, and then Apache.

Verification

  1. Verify the Apache welcome page at http://localhost

  2. Verify the Tomcat examples at http://localhost:8080/examples/

  3. Verify Tomcat examples available on port 80 at http://localhost/examples/

Multiple instances of Tomcat on Windows

Running multiple instances of Tomcat is useful if you want to have a live and a development environment.

  1. Copy installed version of Tomcat to another folder.
  2. Go into the \bin directory and rename the files tomcat6w and tomcat6 to tomcat6devw and tomcat6dev.
  3. Go into the \conf directory and modify the server.xml file and change the ports to something else, above 1024. These are the values I have set them to for this example.

    <Connector port="8081" protocol="HTTP/1.1" 
    <Connector port="8001" protocol="AJP/1.3" redirectPort="8441" />
    <Server port="8002" shutdown="SHUTDOWN"> 
  4. Open up a command prompt and go to the \bin directory of your new tomcat and run this command. (make sure to change the directories to match your environment)

    tomcat6 //IS//Tomcat6Dev --DisplayName="Apache Tomcat 6 Dev" --Install="C:\TC_Test\tomcat\bin\tomcat6dev.exe" --Jvm=auto --StartMode=jvm --StopMode=jvm --StartClass=org.apache.catalina.startup.Bootstrap --StartParams=start --StopClass=org.apache.catalina.startup.Bootstrap --StopParam=stop
  5. To control the new Tomcat server you can use the tomcat6devw.exe program located in tomcat\bin
    • Alternatively you can create a new shortcut to the Apache Tomcat monitor program by.
      • Opening the Start menu "Startup" folder.
      • Copy the existing tomcat monitor startup item.
      • Then modify the Path and Service Values in the properties of the shortcut to reference your new server.
    • Another method is by changing the startup type of the Tomcat service in the tomcat6devw.exe


See also:

References/External Links

Wiki: dedicated/tomcat_with_apache_on_windows_x64 (last edited 2009-03-06 11:27:24 by SajGoonatilleke)