NETWORKING
   Home >  Networking >  VoIP > 

How to install Apache and Tomcat to serve JSP pages on a MS Windows server


This is a step-by-step guide to installing Apache and Tomcat to server JSP pages on a MS Windows server.  This guide assumes you know how to locate and download all the files you need and that you know how to do basic administration stuff on the windows machine like install software, set environmental variables, use the DOS command prompt, etc.  This guide does not explain why you are doing certain steps, or how to customize your installation.  It will hopefully help you at least get up-and-running.  After that, you should refer to the Tomcat User's Guide and also the Apache-Tomcat HOWTO guide (both available on apache.org).  It should be mentioned that I have a very fragile grasp on how this works, so although it seems to work, I have no idea if this is the most optimal way to set things up.  Updates and corrections would be appreciated (see URL below for contact information).

The following file paths will be used in these instructions.  If you install to a different directory, then you'll want to change the instructions accordingly.  These seem to be the default installation directories for the programs, except for Tomcat, which doesn't mention a default installation directory.

Java: C:\JDK1.3
Apache: C:\Program Files\Apache Group\Apache
Tomcat: C:\Tomcat

  1. Download (from sun.com) and Install Win32 JDK 1.3 to "C:\JDK1.3"

  2. Download (from apache.org) and Install Win32 Apache with all defaults "C:\Program Files\Apache Group\Apache" If you are already running another web server on this machine (like IIS or PWS), you will probably want to go to Start->Programs->ApacheWebServer->Management->Edit Configuration (or simply open the Apache httpd.conf file) and scroll down until you see port 80. Change this to another port (I used port 8181) Start Apache and make sure it is running by opening your browser to http://localhost:8181/ (if you used port 8181 like I did)

  3. Download (from apache.org) and unzip Win32 binary version of Tomcat (jakarta-tomcat) to "C:\Tomcat"

  4. Download (from apache.org) ApacheModuleJServ.dll and copy to "C:\Program Files\Apache Group\Apache\Modules"

  5. Right-Click on My Computer -> Properties, go to Evironmental Variables* and set:

    TOMCAT_HOME = C:\Tomcat
    JAVA_HOME = C:\JDK1.3< /EM >
    * On Win2000, The environmental variables are found on the Advanced tab.  If you are on Win95/98, then you probably have to edit autoexec.bat instead.

  6. In the environmental variables, make sure "C:\JDK1.3\bin" is the first directory in your PATH. If you have installed other Java programs, they may try to put their Java Run-Time directory first, which will mess up your Tomcat installation.  (It's also good to keep in mind that if you install another Java application later, it might try to change the path and mess up Tomcat)

  7. Restart the computer to finalize changes to PATH

  8. Go to DOS prompt, CD to C:\Tomcat\Bin and start Tomcat by typing "startup" (without the quotes).  You should get a 2nd DOS window that is running Tomcat. If the 2nd window flashes and immediately closes, then something is wrong - most likely your PATH

  9. If Tomcat started successfully, a file will be created: C:\Tomcat\conf\tomcat-apache.conf. Copy this file to "C:\Program Files\Apache Group\Apache"  You can make sure Tomcat is running by opening your browser to http://localhost:8080/ (NOTE: If you have previously installed Sun's JavaWebServer, make sure it is not running because it also uses port 8080)

  10. Edit the httpd.conf file (again like in step 2) and append the following line to the end:

    Include tomcat-apache.conf

  11. Start Apache

  12. Create a new text file called hello.jsp and copy it to "C:\Tomcat\WebApps\Examples" put the following in the file:

    <html>
    <% out.print("It Worked!"); %>
    </html>

  13. Open your browser to http://localhost:8181/examples/hello.jsp If you see "it worked" on the screen then you are in business.

How to configure a new virtual directory for your jsp files.

Here is an example of adding a new virtual directory (or "context") for your jsp files.  If you are like me, then you don't want to keep your web pages in the Tomcat or Apache program directory.  The following will map a new directory "C:\InetPub\jspRoot\" to this virtual URL: http://localhost:8181/jsp/   This assumes that you have followed all of the above instructions.  Use your own directory paths if you have customized things.

First create a directory: C:\InetPub\jspRoot

Add this to the end of C:\Program Files\Apache Group\Apache\tomcat-apache.conf

<Directory "/jsp">
     Options Indexes FollowSymLinks
</Directory>
ApJServMount /jsp/servlet /jsp
<Location /jsp/WEB-INF/>
     AllowOverride None
     deny from all
</Location>

Add this to the end of C:\Tomcat\conf\server.xml

<Context path="/jsp" docBase="C:/InetPub/jspRoot" debug="0" reloadable="true"/>
</Contact>

To finalize the changes, restart Tomcat and Apache.