Share this blog
- Morfik Discussion Forums rules and guidelines
- MDA Release: The FacebookLike Package
- MDA Release: The Rating Package
- MDA Release: The HTML5 Video Package
- MDA Release: The Accordion Package
- April 2011 (1)
- January 2011 (4)
- December 2010 (2)
- November 2010 (3)
- October 2010 (5)
- September 2010 (4)
- August 2010 (6)
- July 2010 (6)
- June 2010 (4)
- May 2010 (5)
- April 2010 (9)
- March 2010 (7)
- February 2010 (17)
- January 2010 (19)
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).
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).
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.
For the next step, Advanced Instance Options, I find the default values are fine, as shown below.
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.
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.
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”.
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”.
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.
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.
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!
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!