Working with Amazon Web Services (EC2)
Join the DZone community and get the full member experience.Join For Free
as posted before i attended to a technical handson aws training last week. the subjects during these days were of course the standard ec2 and s3 services which i have used before. added to that we worked with rds , elastic load balancing , sns and vpc , elastic beanstalk and discussed a lot of terminology and business cases.
in this post i setup a new ec2 server and connect to it with your macos although it will work similar in case of linux. i have an account at aws in place. before you start make sure you have selected the correct region (for a simple demo it isn’t very big thing but when you are going to setup a real server it can make a big difference in the costs (network traffic) and latency although there are solutions for that).
by the way, there are two approaches to setup your ec2 server, you can choose a “s3 backed” ami ( amazon machine image ) or a “ebs-bakced” ami. there are a lot of good articles available about the differences and when to use which one.
in this demo i will install a “pre-baked” ami with a complete wordpress setup installed. there are thousands of these ami’s available in the aws community. for this one launch the aws management console at http://aws.amazon.com and choose the ec2 tab. in the aws console make certain you selected the correct region and select ‘images-amis’ in the left menu and search for “bitnami-wordpress”:
select the ami of your choice (i have 64-bit ubuntu running wordpress 188.8.131.52) and click ‘launch’. now simply follow the steps of the wizard (although there is a lot to tell about almost every option in the wizard i simply go for the most default installation). at the instance details step make sure you select a micro instance (to cut down the cost of having this demo running):
in the next two steps simply accept all defaults:
at the create key pair step create a key pair if you haven’t already done so:
the next step configure firewall create a security group so we are able to access our linux instance from the outside world by http and ssh:
finally review all your settings and if it is okay then launch the instance:
after a few seconds you should be able to see your new instance in the instances overview in the aws management console:
please pay specific attention to the public dns that is assigned to the instance. as you might be aware this dns will change after you stopped and started this instance. so i use it now to show how to connect to the instance via ssh but you should not use this dns as if it was a fixed ip/dns. to work around this issue amazon supplies elastic ip which i show in another post.
to connect with ssh to this instance open up a terminal on your mac and type the following commands.
first i had to narrow the permissions on the downloaded pem file for which i used:
chmod u=r,go= 4synergy_palma.pem
then i was able to connect to the bitnami instance via ssh with:
and of course we can enter our wordpress by opening the home url in a web browser:
in the next posts i will extend this example to make it a more robust and scalable solution.
Opinions expressed by DZone contributors are their own.