Installing and Configuring Tomcat: A Quick Guide To Getting Things Set Up On Windows
Installing and Configuring Tomcat: A Quick Guide To Getting Things Set Up On Windows
Setup Environment
I will assume everyone will be using Windows. Also make sure you have the Java SDK installed on your PC.
The SDK includes the java compiler and some other tools as well as the runtime environment. You need the compiler to run tomcat.
Installing Tomcat
Go to the Jakarta binaries web site:
http://jakarta.apache.org/site/binindex.cgi
Running Tomcat
In the Tomcat folder, open the bin folder. Click the startup.bat icon. You should see a black and white Java command window.
You should not see any obvious java error messages.
Note startup.bat actually calls other scripts in the same directory (catalina.bat, particularly). The .sh files are for running Tomcat on Linux/Unix
Maybe Mac also.
Problems
Tomcat failures to start correctly if
you either do not have the Java SDK installed on, or your JAVA_HOME environment variable is set incorrectly.
You must have the Java SDK installed, since you need javac.
So to really test things out and to understand what is going on, you should set up and run two web servers.
Preferably on two different machines.
Installing a second server on the same host follows all of the same steps as before, with one additional step.
You must modify server.xml
Finding server.xml
The file server.xml has all of the server configuration information. This is located in the folder jakarta-tomcat-5.0.19/conf. You only need to edit it in two places.
See next slide
Double click it to open it with your favorite text editor. Make a backup copy of server.xml before you change things.
Tomcat Ports
Tomcat 5s default settings listen to three ports: 8080, 8005, 8009.
8080 is the http port number. 8005 is the shutdown port.
You can contact this to shutdown Tomcat from another process.
8009 is the AJP port for running Tomcat behind an Apache server.
Not needed here, but port opened
Changing Ports
Only one server at a time can accept connections on ports 8080, 8005, and 8009. If you want run a second Tomcat server, you must change the values of these ports for the second server. Just edit server.xml to change these ports.
Shutdown the server first. Values dont matter For Linux/Unix, values <1024 are owned by root processes so you normally cant use these values.
Now restart the server. Point your browser at the new port number to check.
http://localhost:9090 for example.
Editing server.xml
The following slides show the config settings that you need to change the shutdown, http, and ajp ports. You can freely change other parameters if you want. Note of course you are taking advantage of your basic XML knowledge.
Shutdown port
<!-- A "Server" is a singleton element that represents the entire JVM, which may contain one or more "Service" instances. The Server listens for a shutdown command on the indicated port. Note: A "Server" is not itself a "Container", so you may not define subcomponents such as "Valves" or "Loggers" at this level. --> <Server port="9005" shutdown="SHUTDOWN" debug="0">
HTTP Connector
<!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 --> <Connector port="9090" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" disableUploadTimeout="true" /> <!-- Note : To disable connection timeouts, set connectionTimeout value to 0 -->
AJP Port
<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 --> <Connector port="9009" enableLookups="false" redirectPort="8443" debug="0" protocol="AJP/1.3" />