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

  • The Apache install is straightforward, specify the install directory to c:/apache/httpd to make configuring the links to Tomcat later on easier.

Java JDK

  • You can safely install the JDK with all the default values. You should only need to consider a custom installation if you are using a CMS which requires a specific installation location.

Apache Tomcat

  • Install Tomcat into c:\apache\tomcat You can change this but avoid directories with spaces or non-ASCII characters in their names. This article assumes this installation location is used.

  • If you are using 64bit Windows you will need to locate the "msvcr71.dll" this is located on your original Windows CD as it is not installed by default, and copy it into the tomcat\bin directory.

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

  • You should be able to view your default Apache install by vising http://localhost and getting an "IT WORKS" page.

If you don't get this page check:

  • That you don't have another service running on port 80, or
  • Ensure that the Apache service is started in the Apache Monitor application. The monitor application will also help you identify reasons why the service has not started.

Apache Tomcat

  • To view the Tomcat default page visit http://localhost:8080 (8080 is the default unless you changed it!) If you don't get this page check:

    • That you don't have another service running on port 8080, or
    • Ensure that the Tomcat service is started in the Tomcat Monitor application. The monitor application will also help you identify reasons why the service has not started.

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