Host Apache Tomcat Server on Linode Public Server

Setting up Apache Tomcat web server on publicly hosted Linux host is a best way to host your service.

If you want to publish any Java application to world, you need public IP and hence public facing host. Using that you could host your Java application on Tomcat and access using Public URL.

If you have any of below questions then you are at right place:

  • How to configure Tomcat to be accessible on internet?
  • How to make my IP publicly accessible to make my local Tomcat server public?
  • How to install Tomcat 9 on Ubuntu 18.10?
  • How do I start Tomcat in Ubuntu?
  • How do I start Tomcat in Linux?
  • How do I check if Java is installed on Ubuntu?
  • How to Install and Configure Apache Tomcat 9 on Ubuntu?

Let’s get started:

Step-1

  • Register for a host on Linode
  • Once login you will be redirected to https://cloud.linode.com/dashboard
  • Click on Create and Select Linode
Create Linode Step-1

Step-2

Next step is to provide all details for your Linode.

  • For Image: choose Ubuntu
  • For Region: choose US Dallas or your preferred region
  • For Linode Plan: Select Nanode which is just $5/month (1GB: 1 CPU, 25G Storage, 1G RAM)
  • Set Linode Label: crunchify
  • Set password
  • Click Create button
Linode Select Image, Region and Plan
Linode Set Password and Label

Step-3

From left panel click on Linodes and click on crunchify.

New Crunchify Linode Created

Step-4

Click on Networking Tab.

Login to Newly Created Linode from networking Tab

Open Terminal Window if you are on Mac OSX. For Windows you could use putty client.

use command ssh root@45.56.77.82 to login to your newly created host.

bash-3.2$ ssh root@45.56.77.82
Warning: Permanently added '45.56.77.82' (ECDSA) to the list of known hosts.
root@45.56.77.82's password: 
Welcome to Ubuntu 18.10 (GNU/Linux 4.18.0-13-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Thu Jan 10 20:48:00 UTC 2019

  System load:  0.0               Processes:           93
  Usage of /:   8.6% of 24.06GB   Users logged in:     1
  Memory usage: 12%               IP address for eth0: 45.56.77.82
  Swap usage:   0%

 * MicroK8s is Kubernetes in a snap. Made by devs for devs.
   One quick install on a workstation, VM, or appliance.

   - https://bit.ly/microk8s

 * Full K8s GPU support is now available!

   - https://blog.ubuntu.com/2018/12/10/using-gpgpus-with-kubernetes


0 packages can be updated.
0 updates are security updates.

Step-5

Next step is to install Java/JDK. Just use below command to install JDK.

root@crunchify:~# sudo apt install default-jre

Verify if java is installed or not?

root@crunchify:~# which java
/usr/bin/java

root@crunchify:~# java -version
openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment (build 11.0.1+13-Ubuntu-2ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.1+13-Ubuntu-2ubuntu1, mixed mode, sharing)

Step-6

Install Apache Tomcat on Linux host. Follow below linux commands.

root@crunchify:~# cd /

root@crunchify:/# mkdir crunchify

root@crunchify:/# cd crunchify/

root@crunchify:/crunchify# wget http://apache.cs.utah.edu/tomcat/tomcat-9/v9.0.14/bin/apache-tomcat-9.0.14.zip

root@crunchify:/crunchify# apt install unzip

root@crunchify:/crunchify# unzip apache-tomcat-9.0.14.zip 

root@crunchify:/crunchify# chmod -R 777 apache-tomcat-9.0.14

root@crunchify:/crunchify# cd apache-tomcat-9.0.14/bin/

root@crunchify:/crunchify/apache-tomcat-9.0.14/bin# ./catalina.sh start -d
Using CATALINA_BASE:   /crunchify/apache-tomcat-9.0.14
Using CATALINA_HOME:   /crunchify/apache-tomcat-9.0.14
Using CATALINA_TMPDIR: /crunchify/apache-tomcat-9.0.14/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /crunchify/apache-tomcat-9.0.14/bin/bootstrap.jar:/crunchify/apache-tomcat-9.0.14/bin/tomcat-juli.jar
Tomcat started.

How to check if Tomcat process is up and running?

root@crunchify:/crunchify/apache-tomcat-9.0.14/bin# ps -few | grep tomcat

root     15854     1 11 20:58 pts/1    00:00:03 /usr/bin/java -Djava.util.logging.config.file=/crunchify/apache-tomcat-9.0.14/conf/logging.properties 
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 
-Djdk.tls.ephemeralDHKeySize=2048 
-Djava.protocol.handler.pkgs=org.apache.catalina.webresources 
-Dorg.apache.catalina.security.SecurityListener.UMASK=0027 
-Dignore.endorsed.dirs= 
-classpath /crunchify/apache-tomcat-9.0.14/bin/bootstrap.jar:/crunchify/apache-tomca-9.0.14/bin/tomcat-juli.jar 
-Dcatalina.base=/crunchify/apache-tomcat-9.0.14 
-Dcatalina.home=/crunchify/apache-tomcat-9.0.14 
-Djava.io.tmpdir=/crunchify/apache-tomcat-9.0.14/temp org.apache.catalina.startup.Bootstrap 
-d start
Apache Tomcat Process is up and Running - Crunchify Tips

Step-7

Now it’s time to verify Apache Tomcat Process using Browser URL.

By default Tomcat runs on port 8080. Just go to http://45.56.77.82:8080/ and you will your tomcat running on port 8080.

Host Apache Tomcat Server on Linode Public Server

And you are all set. Let me know if you face any issue running Tomcat Server on newly created Linode node.

The post How to install & setup Apache Tomcat server on Linux Ubuntu host [on Linode] appeared first on Crunchify.