Step-by-step guide for installing tomcat on unix

Here below we provide a step-by-step guide for installing and setting up tomcat in unix environment, for those who are interested in windows machines you can refer to this guide.

1. Prerequisite

Tomcat doesn’t work without java, so before installing tomcat on the machine, you should install a compatible java runtime version and setup JAVA_HOME environment variable. Both java and tomcat versions should be compatible so i recommend to always install the same version for java and tomcat, in this tutorial we use java 8 and tomcat 8.

Follow this tutorial to setup java on your unix machine.

2. Installation

Following are the steps for setting up tomcat 8 on unix machine:

  1. Download tomcat8 from here into your home directory .i.e. /home/PG
  2. Create a new directory called tomcat8 under /usr/local.
  3. Move the downloaded file to /usr/local/tomcat8 and extract it there.

Now set the path of CATALINA_HOME environment variable to /usr/local/tomcat8/apache-tomcat-8.5.15

And here you go, tomcat is installed successfully on your machine.

To start tomcat:

To shut down tomcat:

 3. Configuration

To change the default running port of tomcat:

Then change the port attribute of Connector tag as the following:

Here, we set tomcat to run on port 9095 , a restart is required for the change to take effect.

Check if tomcat is up

In order to make sure that tomcat is started up correctly on the configured port, just run <ip>:9095 url on any browser and if you get the following screen then tomcat is up and ready to serve requests.

Alternatively, you can check if there exist a running tomcat process through executing the following command:

 4. Tomcat Logging

Tomcat log files can be found under $CATALINA_HOME/logs, there are 2 important log files to be checked when investigating applications issues:

  • tomcat8-stderr.<date>.log: This file logs all the runtime exceptions which are thrown by the running application.
  • tomcat8-stdout.<date>.logThis file displays all the trace and info logs generated by the application.

OR if these files are not found, you can check catalina.<date>.log which holds all the exceptions and info logs generated by the application.

 

husseinterek

Founder of programmergate.com, I have a passion in software engineering and everything related to java environment.

You may also like...

Leave a Reply

1 Comment on "Step-by-step guide for installing tomcat on unix"

avatar
newest oldest most voted
Zaher
Guest

Great article, this helped very much… Much appreciated