Thursday, March 24, 2011

Installing Apache Tomcat 6 on Windows XP


After days of fiddling and frustration, I finally got Apache Tomcat 6 running on my Windows XP. I found that most of the instruction on the web were useful but none of them were complete. I figure I will post my steps here.

1. Install JDK
Download Java Development Kit and install it. Note that I cannot get Tomcat6 to work with just JRE. Therefore, I install JDK which include JRE already. At the time of writing, the version number is Java SE 6 Update 24, the filename is jdk-6u24-windows-i586.exe. Install it to C:\Program Files\Java\jdk1.6.0_24

2. Install Tomcat6
Download Tomcat 6 from its website.
On the contrary to most instructions on the web, there is no Windows Service Installer (i.e. exe file. Only zip file is available. At the time of writing, the version number is 6.0.32, the filename is Unzip it to C:\Program Files\Java\apache-tomcat-6.0.32.

3. Setup environment variables
Goto Control Panel->System->Advanced->Environment Variables. Create 3 System Variables:
CATALINA_HOME=C:\Program Files\Java\apache-tomcat-6.0.32
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_24
JRE_HOME=C:\Program Files\Java\jre6
Add one more path to Path variable:
Path=.....;C:\Program Files\Java\jdk1.6\bin

4. Setup server port (optional)
Edit $CATALINA_HOM\conf\server.xml. Locate Connector port="8080". Change it to the port you want. e.g. 8087

5. Setup manager
Edit $CATALINA_HOM\conf\tomcat-users.xml. Uncomment the role section and change it to:

<role rolename="tomcat" />
<role rolename="manager" />
<user username="tomcat" password="tomcat" roles="tomcat" />
<user username="both" password="tomcat" roles="tomcat,role1" />
<user username="admin" password="admin" roles="manager" />

6. Run it
From a command Prompt, cd to C:\Program Files\Java\apache-tomcat-6.0.32\bin. Run the startup.bat

7. Check if it works
On a web browser, go to http://localhost:8087. If it works, the picture above will be displayed. You can now click the Tomcat Manager link using the username admin & password admin.