1.  Extract Tomcat to a directory.
  2.  The Tomcat start scripts are located in <tomcat>/bin
  3. Tomcat is started by running startup.bat (on windows) or startup.sh (on linux)
  4.  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).
  5.  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:

tc1

If JAVA_HOME does not exist, set it to your JDK.

Eg.

C:/Program Files/Java/jdk1.6.0_07

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:

tc2

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.

http://localhost:8080

This tells the browser to make a HTTP request to the local computer on port 8080.
You should see something like:

tc3

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:

www.google.com

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″

connectionTimeout=”20000″

redirectPort=”8443″ />

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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s