Prerequisites: a rough understanding of the command line and you have used ssh before.
So if you are interested in setting up a web application on a cloud machine from scratch, I have set up https://www.simpleaffablebean.org on my own Digital Ocean cloud machine.
Digital Ocean is an online cloud provider, simpler to use than Amazon Web Services or Google Cloud Platform.
You can sign up for them at do.co/twit (for a free $100 credit, should last 20 months if you choose the cheapest server).
When you sign up, you get to choose specifications for your “droplet” (aka your cloud box).
Choose an Ubuntu 16.04 server for now (I should choose 18.04 eventually but it’s not a great idea to go so close to the bleeding edge).
We can now work through a series of excellent documentation pages.
Initial Server Setup with Ubuntu 16.04
Create a systemd Service File
Note: To save memory, I used the following instead of that suggested:
Environment='CATALINA_OPTS=-Xms512M -Xmx512M -server -XX:+UseParallelGC'
I only allowed the following services:
sudo ufw allow 3306
) *nat
:PREROUTING ACCEPT [0:0]
-A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
-A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8443
COMMIT
Create a user
mysql> create user 'yourDatabaseUserName'@'%' identified by 'yourStrongDatabaseUserPassword';
Create a database
mysql> create database YourDB;
mysql> grant all privileges on yourDatabaseUserName.* to 'YourDB'@'%';
Populate the Database
/src/main/db/tables.sql and src/main/db/data.sql.
Using your own hostname (like simpleaffablebean.org) if you want to, otherwise stick with the raw IP address for now.
On your laptop, update context.xml to use:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/">
<Resource name="jdbc/YourJDBCName" auth="Container" type="javax.sql.DataSource"
maxTotal="5" maxIdle="2" maxWaitMillis="10000"
username="yourDatabaseUserName" password="yourStrongDatabaseUserPassword"
driverClassName="com.mysql.cj.jdbc.Driver"
removeAbandonedOnBorrow="true" removeAbandonedOnMaintenance="true"
removeAbandonedTimeout="60" logAbandoned="true" timeBetweenEvictionRunsMillis="300000"
url="jdbc:mysql://yourDropletIP_Or_HostName:3306/YourDB"/>
</Context>
Build Your WAR File on your laptop
gradle clean build war -x test
Deploy your WAR file to the Tomcat on your Droplet
systemctl restart tomcat
That’s all I learned from setting up www.simpleaffablebean.org, I hope you are as lucky.