- Extract Tomcat to a directory.
- The Tomcat start scripts are located in <tomcat>/bin
- Tomcat is started by running startup.bat (on windows) or startup.sh (on linux)
- However before this can be done the JAVA_HOME environment variable needs to be set. Tomcat uses this environment variable to find a Java Development Kit (JDK).
- In windows you can view and edit the environment variables by right clicking “My Computer” and clicking properties. Then click on the “Advanced” tab and click the “Environment Variables” button. You should see a window like this:
If JAVA_HOME does not exist, set it to your JDK.
If you are using linux, add “export JAVA_HOME=<Path to JDK>” to your profile.
Start Tomcat by running startup.bat. You should see a terminal that looks something like this:
If Tomcat has started correctly you should see a line at the bottom saying
“Server startup in ??? ms”.
Tomcat is now running.
Now open a browser and enter the following address.
This tells the browser to make a HTTP request to the local computer on port 8080.
You should see something like:
This is the default Tomcat page.
We had to put the :8080 in the url to make the browser send the request to port 8080 as Tomcat defaults to listening on this port. However we don’t want to have to enter this every time we request one of our pages.
When you enter a URL in a browser like:
The browser makes a request to the computer at www.google.com on port 80. So we should configure Tomcat to listen on port 80.
If Tomcat is still running stop it by running “shutdown.bat” in the bin directory.
Open the file <Tomcat>/conf/server.xml. This is the main configuration file for Tomcat. Look for a line like:
<Connector port=”8080″ protocol=”HTTP/1.1″
Change the 8080 to 80.
Be careful not to confuse this line with the line:
<Server port=”8005″ shutdown=”SHUTDOWN”>
This is the port tomcat listens to for requests to shut it down. Leave this line as it is.
Save the file.
Restart Tomcat. You should now be able to enter http://localhost/ into a browser and get the same page you got before.
Tomcat is now setup and we can start creating web applications