Install Tomcat 7 on Windows 7

In continuing with building a testing environment on Windows 7 / Windows 2008 R2 I have embarked on installing Apache Tomcat 7 on my Windows 7 desktop. First download 32 or 64 bit from will find the download links in the binary distributions section of the page. You will also need to make sure you have Jave jdk installed.

My current setup is 32 bit running Apache 2.2.22 with PHP 5.4.0, so I am going with Once the download is completed, just extract the zip file to the directory of your choosing. For this example I have chosen c:\apps\apache-tomcat-7.0.28.

Configure Tomcat

Now we to set a few properties for Tomcat to know where the JDK is installed. We do this by creating the setenv script file. Since we are running 32 bit windows instance, it is best to use a 32 bit instance of the JDK. Open your favorite text editor and create a file called setenv.bat with the following contents:

set "JRE_HOME=%ProgramFiles(x86)%\Java\jre6"
exit /b 0

Save the file to c:\apps\apache-tomcat-7.0.28\bin. That’s all you have to do with the bat file. The catalina.bat file will look for and execute it if it finds the file.

Setting up the Windows Service

Now we need to setup Tomcat to run as a service. Open a command prompt us9ing Run as Administrator option and change into the directory you extracted Tomcat to.

cd C:\apps\apache-tomcat-7.0.28\bin

Run setenv.bat that you just created to set JRE_HOME variable and run service.bat script with the following syntax.

Usage: service.bat install/remove [service_name] [/user username]

service.bat install Tomcat7

The service will now appear in Service as Apache Tomcat [your name] and set as Manual.

At this point you can start the service as well as change it to Automatic. Open a browser and type in http://localhost:8080 and you should be greeted with the standard Tomcat page.

You should now have a working installation of Tomcat 7 on your Windows 7 / Windows 2008 R2 system. Next step is to set the username and password for accessing Tomcat Manager app. By default this is commented out in the %TOMCAT_FOLDER%/conf/tomcat-users.xml file. Open the file with a text editor an un-comment the section in tomcat-users.
<role rolename=”tomcat”/>
<role rolename=”role1″/>
<user username=”tomcat” password=”tomcat” roles=”tomcat”/>
<user username=”both” password=”tomcat” roles=”tomcat,role1″/>
<user username=”role1″ password=”tomcat” roles=”role1″/>

Using this configuration will not allow to access the manager and host information. You will also need to add the manager-gui and admin-gui role to access the status and other functions. So you could change the tomcat-users.xml to look like.

<role rolename=”manager-gui”/>
<role rolename=”admin-gui”/>
<user username=”manager” password=”tomcat” roles=”manager-gui,admin-gui”/>

Save this and restart the Tomcat service and you should now be able to access those screens.  Make sure to use stronger passwords than the defaults.


3 Responses to “Install Tomcat 7 on Windows 7”

  1. Rick Bala says:

    Thank you so much. I was getting troubled to start tomcat7 on my station, so i update my JRE 6.0 to the latest version jre6u41 and it worked fine, and as a service! Keep up with the good work!

  2. Seth says:

    Thanks for the clear, concise, and simple tutorial for Tomcat!!!

  3. vishal says:

    Thanks a lot nice…

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.