Apache Tomcat 8.x: How to install and configure?

Apache Tomcat is a pretty famous open source web-server, developed by the Apache Software Foundation. It provides an environment to run Java code with in.

In this article I am going to explain the steps to install and configure Apache Tomcat on “Windows 7” based system. We need Java to run Apache Tomcat web-server; I am assuming Java is already installed on the system.

Step 1. Download the latest version of Apache Tomcat from the website http://tomcat.apache.org/.

Sep 2. Once downloaded, extract the downloaded file into a specific location.

For example: the files are extracted into “C:\apache-tomcat-8.0.9” folder. Now the folder contains the following structure:

<DIR>          bin
<DIR>          conf
<DIR>          lib
<DIR>          logs
<DIR>          temp
<DIR>          webapps
<DIR>          work

Now lets have a look at these folders:

  • bin directory contains some important scripts which are useful to start and shutdown the servers. And also contains some additional scripts which are helpful for server configuration or testing.
  • lib is the Apache Tomcat‘s library directory which contains all library files which are useful to run the Apache Tomcat web-server.
  • conf directory contains the configuration files (“.xml files”) which are useful to configure the servers and containers.
  • Apache Tomcat stores the log files into logs directory.
  • All web applications will goes under webapps directory. For example: if you create a web application “sample”, that should go under webapps folder.
  • work is the directory where Apache Tomcat stores all the generated files.

Other files, contains license, release notes and other useful information to the user.

Step 3. The services in Apache Tomcat are depending on the environment variables and configurations. As of now we are not touch anything related to configuration settings and environment variables. Lets observe what will happen, without setting these.

Lets start running Apache Tomcat. To start, we need to run a script “startup.bat” (for Windows systems) or “startup.sh” (for Unix based systems) which is located in bin directory.

Lets type the below command at command prompt:

Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program

That means, we need to create environment variables JAVA_HOME or JRE_HOME in order to run Apache Tomcat.

Step 4. Create JAVA_HOME or JRE_HOME environment variable and point it to the respective locations where JDK or JRE is installed.

  • JAVA_HOME should point to the location where JDK (Java Development Kit) is installed. For example: if you have installed JDK into “C:\Program Files\Java\jdk1.7.0_65”  location; JAVA_HOME environment variable should point to this location.
  • JRE_HOME should point to the location where JRE (Java Runtime Environment) is installed. For example: if you have installed it in “C:\Program Files\Java\jre7” location; JRE_HOME environment variable should point to this location.

Remember that, we need to have JDK installed on development environment; hence we need to configure JAVA_HOME to make it run Apache Tomcat web-server. But on non-development environments, JRE is enough to install; hence we need to configure JRE_HOME in order to work Apache Tomcat web-server.

Make sure that don’t include the environment variable value within the quotes(“); if we do so, we will see unexpected results.

Step 5. Lets try one more time running “startup.bat” file. This time it will successfully run; it creates another console window where Apache Tomcat server will display any output messages.

Now we are successfully running Apache Tomcat.

Observe that the script automatically creates CATALINA_HOME and CATALINA_BASE environment variables which are required to run Apache Tomcat. These environment variables points to the location where Apache Tomcat is installed. CATALINA_BASE environment variable is used to configure multiple Apache Tomcat instances. If there is only one Tomcat instance; both these environment variables’ values points to the same location; i.e., the installed location of Apache Tomcat.

Step 6. Lets test whether Apache Tomcat is working or not. Type the below URL in address bar of web-browser:


It should display the Apache Tomcat page. That means our Apache Tomcat web-server is working fine.

Apache Tomcat - Test page

Apache Tomcat – Test page

We are successfully installed and configured Apache Tomcat on “Windows 7” based system.


Leave a Reply