Deploying Morfik XApps on Amazon cloud

In the first part of this blog I will take you through the steps involved in setting up and connecting to a virtual machine on Amazon cloud computing services. In the second part I will detail the exact steps involved in installing a Morfik XApp as a native Apache 2 module under Linux.

You might well ask why someone from Morfik would talk about a cloud hosting platform like Amazon. The best thing about cloud computing is the ability to use all the resources you need in a very simple way and pay only for the resources being used.  Just like electricity in your home, you flick the switch and you have light, or turn it off when you don’t need it. Power is at your fingertips and you choose when you access the power.

I’m sure most of you know that the online book (and everything-else) store, Amazon, offers Web Services. But probably very few have used their services. Amazon was the first company to bring cloud computing to the masses and these days they offer a wide range of web services based on the cloud. Morfik has been using cloud hosting from Amazon Web Services (AWS) for a few years now, and it has saved us a lot of time and money.

In a nutshell, Amazon EC2 (Elastic Compute Cloud) is a virtual server which can be commissioned online through a control panel or programmatically through SOAP-API.

In terms of Operating System there are a lot of choices or you can make and customise your own. For the purposes of this blog I’m going to show you how to setup a Fedora Linux virtual server, which is one of the standard options offered by Amazon.

Account setup and EC2 sign-up

Before you can use any of the Amazon web services you need to sign up for a free Amazon Web Services Account. After setting up your account, you need to sign up for Amazon EC2. But don’t worry; no payment is required until you start using their service. You will then need to provide your credit card details and a phone number for online and phone verification purposes. After finishing this process you are ready to setup your first Amazon instance.

Choosing an instance

You can use AWS Management Console to set up your first instance. The first thing to note is the location in which you want the instance to run (Fig.1 below). Our default location is “US West” but you can choose “US East” or “Europe” (Note: Prices vary).

Morfik Deployment on Amazon 1
Fig.1

Security options and obtaining an IP address

There are three important things I like to do at this stage. These steps can be done during the setting up of an instance (or server), but I prefer to do them before starting the launch of an instance.

1-      Create a security “Key Pairs” in order to securely connect to our servers on the cloud. To do this click on the “Key Pairs” menu on the left hand side of the control panel.  Then click on the “Create Key Pair” button on the next page. Give your “Key Pairs” a name and click on the “Create” button. At this time you can save a copy of your private key, “the_name_you_chose.pem”, to your local hard drive.

2-      Create a security group to allow SSH, HTTP and HTTPS protocols to get through. To do this click on “Security Groups” on the right hand side menu and click on “Create Security Group” button. Add a Name and Description and click on the “Create” button. Your new security group will appear on the list. Click on it and at the bottom of the page select the connection methods you need to add. From the drop-down menu select HTTP and then save. Repeat the process to add SSH and HTTPS protocols.

3-      Obtain an IP address. To do this you need to click on the “Elastic IPs” menu,  then the “Allocate New Address” button, and then the “Create” button. (Note: You have to pay extra for this service).

Launching an Instance

After finishing the above steps you now have everything required to launch an instance, which you can now do by clicking on “Instances” in the control panel menu and then clicking on the “Launch Instance” button. As you can see in the screen shot below, there are three (3) tabs; “Quick Start” (Standard Amazon Instances), “My AMIs” (the instances you have set up) and “Community AMIs” (instances provided by Amazon community members).

Morfik Deployment on Amazon 2
Fig.2

For the purposes of this blog I will use the first option in the “Quick Start” tab: “Getting Started on Fedora Core 8”.

On the next screen you can select either the “Small” or “High” CPU server type with the option of launching multiple instances of your server. I chose “1” instance and the “Small” Instance Type.

Morfik deployment on Amazon 3
Fig.3

For the next step, Advanced Instance Options, I find the default values are fine, as shown below.

Morfik deployment on Amazon 4
Fig.4

In the next few steps you choose the key pair and Security Group you have already created and then, if you happy with the summary details of your instance, you can finally “Launch” your instance. At this stage you will see your new instance appear on the control panel – its status is pending, indicated by a yellow circle next to it. This indicates that your instance is being prepared.  A few minutes later the yellow circle should turn green and say ”Running”. If you now click on your instance, all the information about your instance will be displayed in the Control Panel area.

Morfik deployment on Amazon 5
Fig.5
Morfik deployment on Amazon 6
Fig.6
Morfik deployment on Amazon 7
Fig.7

Giving your server a public IP address

You can use the “Public DNS” of your server (which can be found in the section which shows information about the instance/server) – it will have an unwieldy name something like this: “ec2-204-236-133-223.us-west-1.compute.amazonaws.com”. However, to connect to your server we will use a much friendlier IP, i.e. the Elastic IP which we created earlier instead. This can be done by clicking on the “Elastic IP” menu in the Control Panel, selecting the IP, and clicking on the “Associate” button at the top of the control panel. You can then associate the IP number to the “Instance ID” of the machine you created earlier (most likely the only option available at this stage). Click on the “Associate” button and the IP address is now the public IP address of your server.

Morfik deployment on Amazon 8
Fig.8

Now that the server is ready and it has a public IP address it is time to connect to it.

Connecting to your server

There are a few programs which can be used to make a secure connection to the server. I quite like both PuTTY for Windows and Bitvise Tunnelier. But for the purpose of this exercise, I will just go through the process of using PuTTY to connect to our server.

First we need to download and install PuTTY for Windows on our local computer. Then we need to set up PuTTY to connect to our server. But before we do that there is one more essential step – we need to convert the ”Key Pair” (which we created on Amazon and saved a copy of onto our local drive) to a key that PuTTY can use for connection to the server. To do this run “puttygen.exe”, which is located under the same folder as PuTTY. Click on the “Load” button and find and load the key. (If this process was successful you will see the message as shown on the screen shots below.) Now click on the “Save Private Key” button. You can choose a password to secure your private key. After saving this you should have a file called “whatever_theKey_name_was.ppk”.

Puttygen1
Fig.9
Puttygen2
Fig.10
Puttygen3
Fig.11

Start PuTTY and on the first page, under “Host Name (or IP address)”, enter the Elastic IP address associated with your EC2 instance (or the Public DNS address). Select “SSH” Connection Type and “Port 22”.

Putty 1
Fig.12

Then click and expand the “SSH” node under the “Category” heading, and click on the “Auth” node, on the right hand side under “Private key file for authentication”. Now click “Browse” and find and load the private key which you converted earlier to PuTTY format.

Putty 2
Fig.13

You are now ready to connect to your server! However, one last thing: before opening the connection you can save your settings so you won’t have to enter the information again next time. To save your settings click on “Session” under “Category”. In the edit box under “Save Session” give your connection a name and then click on the “Save” button. The connection name will be displayed in the list under the edit box. Next time you run PuTTY, simply by double clicking on the name of the connection in the list, you can connect straight to your server.

Putty 3
Fig.14

Now, the last step! Simply click on the “Open” button to open the connection to your server. The server prompt will request you to “login as:” to which you need to respond with “root”. Provided everything was done correctly, as in the screen shot below, you should finally see the prompt command line ready for your commands!

Amazon Cloud Server
Fig.15

I hope you found this blog useful! In my next blog I will explain how you can run a Morfik XApp as a native Apache module on your server.

Until then…… Au revoir!

3 Responses to “Deploying Morfik XApps on Amazon cloud”

December 17th, 2017
JacksonMate says:

The Server “Getting Started on Fedora Core 8” was no longer available and so I choose “Amazon Linux AIM 2013.03”.

I will write some not at the end of his next post if I manage to get my application running on AWS. On any variations resulting from using the server I did. If not I may be asking for help my self being a beginner. lol

Also:

Don’t add a PassPhrase to the Key he does not mentioned this, but as the software complains if you do not add one I figured I would say. You do not need to add a PassPhrase.

When logging in if you use Root it logs you out after a few seconds saying. “Please login as the ec2-user user rather than root user.”. So as it say type “ec2-user” instead of root.

The AWS Security Group list SSH as port 20 and PuTTY list it as port 22. Ignore this as PuTTY on Port 22 works. AWS must also be port 22 and just say port 20 in the UI.

Thank you for great tutorial.

Regards Jackson.

Great start Shahram! I hope in your next article, you cover both internal *and* external Firebird database installation.

Aquiles Rodriguez says:

Thanks Shahram for this guide, Aquiles

Leave a Reply

Fields marked by an asterisk (*) are required.