CodeSteps

Python, C, C++, C#, PowerShell, Android, Visual C++, Java ...

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 within.

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
LICENSE
NOTICE
RELEASE-NOTES
RUNNING.txt

Now let’s have a look at these folders:

  • the bin directory contains some important scripts which are useful to start and shut down the servers. And also contains some additional scripts which are helpful for server configuration or testing.
  • the lib is the Apache Tomcat‘s library directory which contains all library files which are useful to run the Apache Tomcat web-server.
  • the conf directory contains the configuration files (“.xml files”) which are useful to configure the servers and containers.
  • Apache Tomcat stores the log files into the logs directory.
  • All web applications will go 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 contain a 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 touching anything related to configuration settings and environment variables. Let’s observe what will happen, without setting these.

Let’s 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 the bin directory.

Let’s type the below command at the command prompt:

c:\apache-tomcat-8.0.9>bin\startup.bat
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 the “C:\Program Files\Java\jdk1.7.0_65”  location; the 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 the “C:\Program Files\Java\jre7” location; the JRE_HOME environment variable should point to this location.

Remember that, we need to have JDK installed on the 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 doesn’t include the environment variable value within the quotes(“); if we do so, we will see unexpected results.

Step 5. Let’s try one more time running the “startup.bat” file. This time it will successfully run; it creates another console window where the 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 point to the location where Apache Tomcat is installed. The CATALINA_BASE environment variable is used to configure multiple Apache Tomcat instances. If there is only one Tomcat instance; both these environment variables’ values point to the same location; i.e., the installed location of Apache Tomcat.

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

http://localhost:8080/

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.

.Paul.

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

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top