Quick guide to installing a Tomcat server and a simple application

The following instructions are for Tomcat 7.0 and assume that Java 6 is already installed.

Installing Tomcat on Windows

  1. Download and run the "Core: Windows Service Installer" from http://tomcat.apache.org/download-70.cgi.
  2. Click "Next", "I Agree", "Next", choose User Name and Password (that you can remember), click "Next", select the path for your Java installation (e.g. jdk.6.0_23), click "Next", "Install" and (after a while) "Finish". The Tomcat server should now be running and there is an icon in the task bar where you can start and stop the server. Also, you should have an "Apache Tomcat 7.0" entry in your Start / All Programs menu.
  3. Open Start / All Programs / Apache Tomcat 7.0 / Tomcat 7.0 Program Directory. Open the conf directory and edit the file tomcat-users.xml by adding an entry containing
      <user name="..." password="..." roles="manager-gui"/>
    
    with your chosen User Name and Password.
  4. Try opening http://localhost:8080 from a browser. This should result in a test page saying "If you're seeing this page via a web browser, it means you've setup Tomcat successfully. Congratulations!"

Installing Tomcat on Linux

  1. Download the "Core: tar.gz" file from http://tomcat.apache.org/download-70.cgi.
  2. Unpack the file (using this command, for example: tar xzf apache-tomcat-7.0.*.tar.gz).
  3. Add an entry to the file conf/tomcat-users.xml containing
      <user name="..." password="..." roles="manager-gui"/>
    
    where you choose (and remember) the name and password.
  4. Start the server with the command bin/startup.sh. Later, you can use bin/shutdown.sh to stop it. Note that these commands should be executed with the Tomcat main directory being the current working directory.
  5. Try opening http://localhost:8080 from a browser. This should result in a test page saying "If you're seeing this page via a web browser, it means you've setup Tomcat successfully. Congratulations!"

Installing Tomcat on Mac OS X

  1. Download the "Core: tar.gz" file from http://tomcat.apache.org/download-70.cgi. The zip file will not do, you must download the "tar.gz" version of the archive.
  2. Open a terminal, in Mac OS X it is located in /Applications/Utilities/Terminal.app.
  3. Navigate to the directory containing the archive you downloaded (using this command, for example: cd /Users/username/Downloads.
  4. Unpack the file (using this command, for example: tar xzf apache-tomcat-7.0.*.tar.gz).
  5. Add an entry to the file conf/tomcat-users.xml containing
      <user name="..." password="..." roles="manager-gui"/>
    
    where you choose (and remember) the name and password.
  6. Start the server with the command bin/startup.sh. Later, you can use bin/shutdown.sh to stop it. Note that these commands should be executed with the Tomcat main directory being the current working directory.
  7. Try opening http://localhost:8080 from a browser. This should result in a test page saying "If you're seeing this page via a web browser, it means you've setup Tomcat successfully. Congratulations!"

Installing a simple application

The following steps are for Windows; with Linux, the "Tomcat 7.0 Program Directory" is the main directory obtained when the tar.gz installation file has been unpacked.
  1. We will now install a simple "hello world" service (see p. 391 in the book). Open Start / All Programs / Apache Tomcat 7.0 / Tomcat 7.0 Program Directory. Open the webapps directory. Create a sub-directory test-app of webapps, a sub-directory WEB-INF of test-app, and a sub-directory classes of WEB-INF. Then download web.xml and put it in the WEB-INF directory, and download HelloWorld.class and put it in the classes directory. That is, the files and directories are structured as follows (see also Section 9.3.1):
     webapps
     test-app
     WEB-INF
     web.xml
     classes
     HelloWorld.class

  2. To start the test application, open http://localhost:8080/manager in a browser. Use the user name and password picked when installing Tomcat. Find /test-app in the list of applications and click the "Start" button to the right.
  3. To run the hello world service, try opening http://localhost:8080/test-app/TEST in a browser. The response should look something like this:
Tips for running your own applications:

back to the main page