SlideShare a Scribd company logo
Setting up a Cloud Server - Part I
Setting up a server in the cloud is probably one of more tedious tasks we need to do. Even if you are a corporate developer who never has to do this I think there is a lot
of value in understanding what goes into this. 

This module is aimed at a quick and dirty deployment. The goal of this tutorial isn’t to teach you scaling or complex ideas. Just to follow thru all the way.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<executable>true</executable>
</configuration>
</plugin>
pom.xml
✦ Executable flag makes the jar runnable in
command line and also makes it work as a Linux
service!
© Codename One 2017 all rights reserved
Before we begin we need to make some changes to the POM file. This is one of the coolest features in spring boot and that says a lot!

You can generate an executable binary script that’s installed in front of the jar. That means you can literally type the name of the jar file on linux and it will run. No java -jar
or anything like that. This might seem trivial but the truly amazing thing is that you can use it as a service on linux which means you can bind it to common system
services in /etc/init.d. If you are not deeply familiar with Linux that might not seem like much but it makes setting up the server MUCH easier.
Server
✦I’ve setup a $5 1gb RAM Centos server on Linode
which is a pretty decent supplier
✦I used MariaDB instead of MySQL since that’s the
default for Centos
✦Linux servers are managed remotely via SSH, if you
use Windows you can use an SSH/SCP client,
since I use a Mac I just used the command line
© Codename One 2017 all rights reserved
I’m a big believer in sustainability. If running your startups backend is $5 per month that gives you a pretty decent chance of running without breaking the bank. A lot of
startups including ourselves make the mistake of over scaling. We used App Engine which was very alluring at the time. The problem is that costs quickly ballooned to
thousands of dollars per month which was totally unjustified, using a VPS is safe and scales with the need of your business. But lets go on and talk about the server
itself.

I used MariaDB instead of mysql in the production. On the desktop I preferred mysql since it had a better installer for Mac OS X. MariaDB is a fork of MySQL that is pretty
much compatible. I normally prefer to have a similar environment on production and development but in this case I use a Mac instead of Linux anyway so I just went with
it.

I use SSH to login to the server. If you use Linux or Mac this is just a command line. For Windows users there are a lot of free SSH clients in the wild and you can use
them.
We’ll start on the Linode site. I’m skipping some of the points related to signup billing etc. I just select the VPS type which in this case is the cheapest option and I create
a new server instance.
Once the server is active we need to install an operating system. I choose to deploy a new image which in this case refers to the disk image effectively this means
operating system install. I choose Centos because I’m used to it and it’s well supported.
I type in the root password which is something you need to remember so don’t lose that… Then deploy. Once I do that the server will take some time to setup. After it’s
done press boot to start up the new VPS.
ssh root@your.ip.address.here
Commands
✦ Login to my server, don’t forget to boot the server
first and set the root password
✦ Notice that once you have a user on the server
it’s “healthier” to login as a user and not as root
© Codename One 2017 all rights reserved
Once the server is booted you can SSH to it with your root password. Notice that you should normally use a user other than root as usage of the root user should be
restricted to a minimum. Root is all powerful. You want to reduce usage of root for a few reasons, the obvious one is that mistakes in root can be costly. But another
reason can be that if your system was compromised with lower privileges a hacker has a good chance of elevating these privileges every time you use root. 

A few years back apache was hacked and the hacker relied on a vulnerability in a script on the site to gain access. The thing is the script was running under a regular
user that isn’t root so he couldn’t really do much… He uploaded an exploit that would give him access to root only if a root user executed a specific command and bingo,
he got root. Had someone not used root the hacker would have been stuck in purgatory for a long time…
#adduser builder
Commands
✦We are adding a new user to the system so we
won’t work as root for the actual process
© Codename One 2017 all rights reserved
So the first thing we do when we get to the server is create a new user called builder. We’ll use that user to run everything. You will notice the sharp character that is the
command prompt of a root user on unix
#passwd builder
Commands
✦Define a password for the new user
© Codename One 2017 all rights reserved
When root invokes the passwd command it doesn’t ask for the existing password as root can override that. Just type in the new password and verify it
#yum install wget
Commands
✦ Yum automatically installs packages on Centos
wget allows us to fetch some tools that we might
need
© Codename One 2017 all rights reserved
In Linux we install packages and dependencies are resolved automatically. The underlying system in Centos is RPM which stands for Redhat Package Manager (Centos
is a fork of RedHat). Yum takes that to the next level by connecting to servers and searching for the RPM packages and all the dependencies and then fetching
everything you need to install.

wget is a tool that can perform an http request to download a file from command line. Since we don’t have a display opening a browser isn’t really practical and this is
reasonably convenient.
#wget --no-cookies --no-check-certificate --header
"Cookie: gpw_e24=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttp%2Fwww.oracle.com%2F;
oraclelicense=accept-securebackup-cookie" "http://
download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-
linux-x64.rpm"
Commands
✦ Oracle makes downloading the JDK rough, you
need to check a box in the website which you
can’t do from a headless box
✦ Alternative is to download to desktop and SCP it
back
© Codename One 2017 all rights reserved
This is a bit of a dirty trick. If you try to download the JDK you will notice that there is no way to get the download link. Oracle hides it until you check a box which means
you need to set a cookie to get it.

That’s really annoying and the only way I found to download the JDK directly to the box was this hack.

The alternative which I’ve used in the past is to download the JDK onto my Mac then use the SCP command to copy it to the server. That’s really slow as I need to
download then upload the file. SCP is “Secure Copy” and it allows copying files over SSH. I’ll discuss it a bit later.
#yum localinstall jdk-8u60-linux-x64.rpm
Commands
✦ Just installs the jdk we downloaded from Oracle
just now
© Codename One 2017 all rights reserved
You remember I said yum fetches things automatically. So you would expect to do something like yum jdk and have the JDK installed. Technically that would work and
might even work here… All Linux distributions ship with OpenJDK which is the open source version of Java. It’s pretty similar but not identical to the Oracle JDK that we
had to download. One of the main reasons I did this was support for JavaFX which doesn’t exist in the JDK. We need it for the CSS compiler and I wanted it to work.

So I’m still using yum instead of rpm directly to install the package. Using yum is important as it can update its install database and resolve dependencies.

More Related Content

Similar to Setting Up a Cloud Server - Part 1 - Transcript.pdf (20)

PDF
Installing WordPress on AWS
Manish Jain
 
PDF
Setting Up a Cloud Server - Part 3 - Transcript.pdf
ShaiAlmog1
 
PPSX
Linux: An Unbeaten Empire
Yogesh Sharma
 
PDF
Linux Administration: A Beginner's Guide 8th Edition Wale Soyinka
rawalbaver9k
 
PDF
Domino9on centos6
a8us
 
ODP
Automated Deployment using Open Source
duskglow
 
PDF
Unixtoolbox
radikalzen
 
PDF
unixtoolbox.pdf
sonipradeep
 
PDF
Unixtoolbox
LILIANA FERNANDEZ
 
PDF
Develop
minimalpk
 
PDF
unixtoolbox.pdf
sonipradeep
 
PDF
unixtoolbox.pdf
sonipradeep
 
PDF
sptlove
 
PDF
unixtoolbox.pdf
qqlove2
 
PDF
qqlove2
 
PDF
unixtoolbox.pdf
sptlove
 
PDF
sptlove
 
PDF
qqlove2
 
PDF
unixtoolbox.pdf
sptlove
 
PDF
sptlove
 
Installing WordPress on AWS
Manish Jain
 
Setting Up a Cloud Server - Part 3 - Transcript.pdf
ShaiAlmog1
 
Linux: An Unbeaten Empire
Yogesh Sharma
 
Linux Administration: A Beginner's Guide 8th Edition Wale Soyinka
rawalbaver9k
 
Domino9on centos6
a8us
 
Automated Deployment using Open Source
duskglow
 
Unixtoolbox
radikalzen
 
unixtoolbox.pdf
sonipradeep
 
Unixtoolbox
LILIANA FERNANDEZ
 
Develop
minimalpk
 
unixtoolbox.pdf
sonipradeep
 
unixtoolbox.pdf
sonipradeep
 
unixtoolbox.pdf
qqlove2
 
unixtoolbox.pdf
sptlove
 
unixtoolbox.pdf
sptlove
 

More from ShaiAlmog1 (20)

PDF
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
ShaiAlmog1
 
PDF
create-netflix-clone-06-client-ui.pdf
ShaiAlmog1
 
PDF
create-netflix-clone-01-introduction_transcript.pdf
ShaiAlmog1
 
PDF
create-netflix-clone-02-server_transcript.pdf
ShaiAlmog1
 
PDF
create-netflix-clone-04-server-continued_transcript.pdf
ShaiAlmog1
 
PDF
create-netflix-clone-01-introduction.pdf
ShaiAlmog1
 
PDF
create-netflix-clone-06-client-ui_transcript.pdf
ShaiAlmog1
 
PDF
create-netflix-clone-03-server.pdf
ShaiAlmog1
 
PDF
create-netflix-clone-04-server-continued.pdf
ShaiAlmog1
 
PDF
create-netflix-clone-05-client-model_transcript.pdf
ShaiAlmog1
 
PDF
create-netflix-clone-03-server_transcript.pdf
ShaiAlmog1
 
PDF
create-netflix-clone-02-server.pdf
ShaiAlmog1
 
PDF
create-netflix-clone-05-client-model.pdf
ShaiAlmog1
 
PDF
Creating a Whatsapp Clone - Part II.pdf
ShaiAlmog1
 
PDF
Creating a Whatsapp Clone - Part IX - Transcript.pdf
ShaiAlmog1
 
PDF
Creating a Whatsapp Clone - Part II - Transcript.pdf
ShaiAlmog1
 
PDF
Creating a Whatsapp Clone - Part V - Transcript.pdf
ShaiAlmog1
 
PDF
Creating a Whatsapp Clone - Part IV - Transcript.pdf
ShaiAlmog1
 
PDF
Creating a Whatsapp Clone - Part IV.pdf
ShaiAlmog1
 
PDF
Creating a Whatsapp Clone - Part I - Transcript.pdf
ShaiAlmog1
 
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
ShaiAlmog1
 
create-netflix-clone-06-client-ui.pdf
ShaiAlmog1
 
create-netflix-clone-01-introduction_transcript.pdf
ShaiAlmog1
 
create-netflix-clone-02-server_transcript.pdf
ShaiAlmog1
 
create-netflix-clone-04-server-continued_transcript.pdf
ShaiAlmog1
 
create-netflix-clone-01-introduction.pdf
ShaiAlmog1
 
create-netflix-clone-06-client-ui_transcript.pdf
ShaiAlmog1
 
create-netflix-clone-03-server.pdf
ShaiAlmog1
 
create-netflix-clone-04-server-continued.pdf
ShaiAlmog1
 
create-netflix-clone-05-client-model_transcript.pdf
ShaiAlmog1
 
create-netflix-clone-03-server_transcript.pdf
ShaiAlmog1
 
create-netflix-clone-02-server.pdf
ShaiAlmog1
 
create-netflix-clone-05-client-model.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part II.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part IX - Transcript.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part II - Transcript.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part V - Transcript.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part IV - Transcript.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part IV.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part I - Transcript.pdf
ShaiAlmog1
 

Recently uploaded (20)

PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 

Setting Up a Cloud Server - Part 1 - Transcript.pdf

  • 1. Setting up a Cloud Server - Part I Setting up a server in the cloud is probably one of more tedious tasks we need to do. Even if you are a corporate developer who never has to do this I think there is a lot of value in understanding what goes into this. This module is aimed at a quick and dirty deployment. The goal of this tutorial isn’t to teach you scaling or complex ideas. Just to follow thru all the way.
  • 2. <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> <executable>true</executable> </configuration> </plugin> pom.xml ✦ Executable flag makes the jar runnable in command line and also makes it work as a Linux service! © Codename One 2017 all rights reserved Before we begin we need to make some changes to the POM file. This is one of the coolest features in spring boot and that says a lot! You can generate an executable binary script that’s installed in front of the jar. That means you can literally type the name of the jar file on linux and it will run. No java -jar or anything like that. This might seem trivial but the truly amazing thing is that you can use it as a service on linux which means you can bind it to common system services in /etc/init.d. If you are not deeply familiar with Linux that might not seem like much but it makes setting up the server MUCH easier.
  • 3. Server ✦I’ve setup a $5 1gb RAM Centos server on Linode which is a pretty decent supplier ✦I used MariaDB instead of MySQL since that’s the default for Centos ✦Linux servers are managed remotely via SSH, if you use Windows you can use an SSH/SCP client, since I use a Mac I just used the command line © Codename One 2017 all rights reserved I’m a big believer in sustainability. If running your startups backend is $5 per month that gives you a pretty decent chance of running without breaking the bank. A lot of startups including ourselves make the mistake of over scaling. We used App Engine which was very alluring at the time. The problem is that costs quickly ballooned to thousands of dollars per month which was totally unjustified, using a VPS is safe and scales with the need of your business. But lets go on and talk about the server itself. I used MariaDB instead of mysql in the production. On the desktop I preferred mysql since it had a better installer for Mac OS X. MariaDB is a fork of MySQL that is pretty much compatible. I normally prefer to have a similar environment on production and development but in this case I use a Mac instead of Linux anyway so I just went with it. I use SSH to login to the server. If you use Linux or Mac this is just a command line. For Windows users there are a lot of free SSH clients in the wild and you can use them.
  • 4. We’ll start on the Linode site. I’m skipping some of the points related to signup billing etc. I just select the VPS type which in this case is the cheapest option and I create a new server instance.
  • 5. Once the server is active we need to install an operating system. I choose to deploy a new image which in this case refers to the disk image effectively this means operating system install. I choose Centos because I’m used to it and it’s well supported.
  • 6. I type in the root password which is something you need to remember so don’t lose that… Then deploy. Once I do that the server will take some time to setup. After it’s done press boot to start up the new VPS.
  • 7. ssh [email protected] Commands ✦ Login to my server, don’t forget to boot the server first and set the root password ✦ Notice that once you have a user on the server it’s “healthier” to login as a user and not as root © Codename One 2017 all rights reserved Once the server is booted you can SSH to it with your root password. Notice that you should normally use a user other than root as usage of the root user should be restricted to a minimum. Root is all powerful. You want to reduce usage of root for a few reasons, the obvious one is that mistakes in root can be costly. But another reason can be that if your system was compromised with lower privileges a hacker has a good chance of elevating these privileges every time you use root. A few years back apache was hacked and the hacker relied on a vulnerability in a script on the site to gain access. The thing is the script was running under a regular user that isn’t root so he couldn’t really do much… He uploaded an exploit that would give him access to root only if a root user executed a specific command and bingo, he got root. Had someone not used root the hacker would have been stuck in purgatory for a long time…
  • 8. #adduser builder Commands ✦We are adding a new user to the system so we won’t work as root for the actual process © Codename One 2017 all rights reserved So the first thing we do when we get to the server is create a new user called builder. We’ll use that user to run everything. You will notice the sharp character that is the command prompt of a root user on unix
  • 9. #passwd builder Commands ✦Define a password for the new user © Codename One 2017 all rights reserved When root invokes the passwd command it doesn’t ask for the existing password as root can override that. Just type in the new password and verify it
  • 10. #yum install wget Commands ✦ Yum automatically installs packages on Centos wget allows us to fetch some tools that we might need © Codename One 2017 all rights reserved In Linux we install packages and dependencies are resolved automatically. The underlying system in Centos is RPM which stands for Redhat Package Manager (Centos is a fork of RedHat). Yum takes that to the next level by connecting to servers and searching for the RPM packages and all the dependencies and then fetching everything you need to install. wget is a tool that can perform an http request to download a file from command line. Since we don’t have a display opening a browser isn’t really practical and this is reasonably convenient.
  • 11. #wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttp%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http:// download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60- linux-x64.rpm" Commands ✦ Oracle makes downloading the JDK rough, you need to check a box in the website which you can’t do from a headless box ✦ Alternative is to download to desktop and SCP it back © Codename One 2017 all rights reserved This is a bit of a dirty trick. If you try to download the JDK you will notice that there is no way to get the download link. Oracle hides it until you check a box which means you need to set a cookie to get it. That’s really annoying and the only way I found to download the JDK directly to the box was this hack. The alternative which I’ve used in the past is to download the JDK onto my Mac then use the SCP command to copy it to the server. That’s really slow as I need to download then upload the file. SCP is “Secure Copy” and it allows copying files over SSH. I’ll discuss it a bit later.
  • 12. #yum localinstall jdk-8u60-linux-x64.rpm Commands ✦ Just installs the jdk we downloaded from Oracle just now © Codename One 2017 all rights reserved You remember I said yum fetches things automatically. So you would expect to do something like yum jdk and have the JDK installed. Technically that would work and might even work here… All Linux distributions ship with OpenJDK which is the open source version of Java. It’s pretty similar but not identical to the Oracle JDK that we had to download. One of the main reasons I did this was support for JavaFX which doesn’t exist in the JDK. We need it for the CSS compiler and I wanted it to work. So I’m still using yum instead of rpm directly to install the package. Using yum is important as it can update its install database and resolve dependencies.