Setting up the environment for hosting your spring boot Application on Ubuntu

Posted 2 September 2018

Once you the developer is done developing your spring boot application,its now time to host your application so that it can be accessed publicly.

Step 1 Purchase a Server You would need to create an account with any of the cloud hosting providers like vultr .Then now login to buy the server of your choice.Steps in purchasing the server can be found here

Step 2 Installing Apache tomcat8 and JAVA

a.Create the tomcat folder : Log in as root, within the opt folder make a directory called tomcat and cd into that folder after completion.As shown below

# mkdir /opt/tomcat
# cd /opt/tomcat

b.Install Tomcat Through wget : Click this link to the Apache Tomcat 8 Download site. Place you cursor under 8.5.32 Binary Distributions,right click on the tar file and select copy link address

# wget http://apache.spinellicreations.com/tomcat/tomcat-8/v8.5.32/bin/apache-tomcat- 8.5.32.tar.gz
After the download completes decompress the file in your tomcat folder
# tar xvzf apache-tomcat-8.5.32.tar.gz

c. Install Java Before you can use Tomcat you’ll have to install the Java Development Kit (JDK). Beforehand, check to see if Java is installed:

# java -version

If that command returns the following message then Java has yet to be installed:
#The program ‘java’ can be found in the following packages:
To install Java, simply run the following command (and at the prompt enter Y to continue):
#apt-get install default-jdk
d.Configure .bashrc file Set the environment variables in .bashrc with the following command:
# vim ~/.bashrc
Add this information to the end of the file:
# export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
# export CATALINA_HOME=/opt/tomcat/apache-tomcat-8.5.32
Save your edits and exit from the .bashrc file, then run the following command to register the changes:
#. ~/.bashrc
e.Test run Tomcat and Java should now be installed and configured on your server. To activate Tomcat, run the following script:
# $CATALINA_HOME/bin/startup.sh
You should get a result similar to:
Using CATALINA_BASE: /opt/tomcat
Using CATALINA_HOME: /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME: /usr/lib/jvm/java-7-openjdk-amd64/
Using CLASSPATH: /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
Tomcat started
To verify that Tomcat is working visit the ip address of you server:8080 in a web browser. For example http://127.0.0.1:8080.
Hurrrrayyyy your apache tomcat is up and running

Its now time to set up the user manager
when you try accessing the page http://127.0.0.1:8080/manager ,this is what you get

To Solve this: 1.First of go $CATALINA_HOME/conf/ on the terminal
2.look up for a file by name tomcat-users.xml and edit by using the nano or the vim command
3.Enable the user manager like below

4.By default,the $CATALINA_HOME/webapps/manager/META-INF/context.xml file will have the following markup.

The Valve section only allow access from 127.x.x.x or ::1. Comment out the Valve section.


Shutdown the Tomcat server.

$CATALINA_HOME/bin/shutdown.sh

Startup the Tomcat server.

$CATALINA_HOME/bin/startup.sh

Post Comments

Leave a Reply