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 http://tomcat.apache.org/download-70.cgi/tomcat-7.0-doc/tomcat-7.0-doc/taglibs/migration.html.You 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 apache-tomcat-7.0.28-windows-x86.zip. 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.
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.
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.
<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.
<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.