Deploy a JAVA Web Application in DigitalOcean

Chanaka Lakmal
Mar 25, 2017 · 3 min read
Source: https://blog.digitalocean.com/sammy-the-shark-gets-a-birthday-makeover-from-simon-oxley

This article explains how to deploy a JAVA web application which have MySQL database in DigitalOcean. You have to do following steps in order.

  1. Create a Droplet with Ubuntu 16.04
  2. Install Apache Tomcat 8
  3. Install MySQL
  4. Install phpMyAdmin
  5. Set Up Apache Virtual Hosts

These steps are already explained as Tutorials in DigitalOcean community. So, I will use those tutorials and connect them with the required modifications.

Step 1

First you have to create and DigitalOcean and create a droplet which is a virtual private server. This is explained in the following tutorial with several steps and you have to follow each and every step of this.

Now you can access,
* Tomcat default splash page :
* Tomcat manager :

Step 2

Next you have to install Apache Tomcat 8 on Ubuntu 16.04 droplet. For this you have to follow each and every step of this tutorial one by one.

If the Step 3 in this tutorial not work for you, then the easiest way to solve this is that manually download from https://tomcat.apache.org/download-80.cgi and SCP the inside directory set and files into /opt/tomcat directory of the droplet.

Step 3

Next you have to install MySQL in order to setup you database in the droplet. For this you have to follow each and every step of this tutorial one by one.

Step 4

Next step is to install phpMyAdmin in order to manage the databases in the droplet. For this you have to follow each and every step of this tutorial one by one.

Now you can access phpMyAdmin :

Step 5

The final step is to setup your virtual host which redirects the request coming to or into where the JAVA web application you are going to deploy in your droplet.

You need to have Apache installed in order to work through these steps. You can get Apache installed on your server through

Before configuring Apache, you should enable the necessary modules.

Next, you are going to modify the default configuration file inside to set up "proxying" functionality.

Run the following command to edit the default Apache virtual host using the nano text editor:

Here, you will be defining a proxy virtual host using and together. Copy-and-paste the below block of configuration, amending it to suit your needs:

<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass / http://0.0.0.0:8080/
ProxyPassReverse / http://0.0.0.0:8080/
ServerName localhost
</VirtualHost>

Press CTRL+X and confirm with Y to save and exit.

Once you are done with your configuration, you will need to restart the cloud server for the changes to go into effect. Execute the following command to restart Apache:

And that’s it! Your installation of prerequisites are complete now! Your are now free to deploy your own Java web applications using Tomcat manager.

Since you have configured port 80 to redirect into 8080 now you can access Tomcat manager using
Create the war file of your web application. Then go to WAR file to deploy section of Tomcat manager and upload the war file and Deploy.

That’s it! You are done with deploying your JAVA web application in DigitalOcean.

Now you can access your web application :


Chanaka Lakmal

Written by

Tech Enthusiast | Software Engineer @ WSO2 | Computer Science Engineering @ UoM | Rotaractor | Maliyadeva College

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade