In this article we will learn how to setup cloud environment with Amazon and setup EC2, Elastic IP, LAMP.

EC2 – Amazon Elastic Compute Cloud (Amazon EC2) is a web service, it allows you to set-up large/small scalable server.

Elastic IP – Elastic IP is static IPV4 address assigned to AWS account which we can use with our EC2 instance.

LAMP – Linux, Apache, MySQL and PHP. This is the server generally people using to run the website/application.

How to setup

First you will require an AWS account, if you do not have please sign up and create new account. It is free (But requires credit card information)

Login to your account and you will see AWS services list on dashboard, just select EC2

 

Select region from top right where you want to setup your EC2 instance.

Once you choose region click on Instances from left menu and click on button Launch Instance. You will see following screen, from that you can select which type of server you want to set up.

After selecting server e.g. Amazon linux, Ubuntu or windows. In our example I am selecting Amazon linux. On next screen it will ask to choose instance type, based on instance type you will be charged hourly so make sure you choose t2.micro if you are setting up server for testing purpose.

Next is configure instance details, leave with the default values and click on add storage type.

Being an app development firm, we understand the importance of storage. Let’s see how can you set the memory:

Add storage screen you can set memory of instance. By default it will show 8GB and minimum you need to set is 4GB, maximum it allows 30GB for free tier.

Next is add tag screen, here you can set tag value for the instance if you do not wish to set you can leave it blank.

Configure security group screen allows us to set-up incoming and outgoing server traffic rules. E.g. SSH, HTTP, HTTPS or any port and set source IP to allow access from specific IP address or you can leave 0.0.0.0/0, ::/0 (anywhere) to allow access from any IP. I recommend to set your IP for SSH. You can choose existing security group if you have already set-up instance previously.

Now it is time to review and launch your instance. Once you click on that button it will show you screen where you can review all detail of instance, after reviewing you can click on launch button and it will take you to choose name your server .pem file and save it on safe place. Now It will take  some time to setup instance. Once it is completed you will see your instance in the list.

Once your server is up you can access your server by IP address but that address will not be static and will be changed when you reboot your instance. For this issue we need to use Elastic IP and associate it with our instance so it will not changed when we reboot our instance.

Check following steps to use Elastic IP.

From left panel choose Elastic IPs and it will show following screen.

Click on Allocate new address and it will assign new IP address, now you can associate that IP to your instance.

Once you click on Associate address, it will ask you to choose which instance/network you would like to associate. Select your proper instance from drop down and click associate button. Now you have successfully associate your instance with new Elastic IP and instance will be accessible with this new Elastic IP and it will not going to change when you reboot your instance.

Now we will check how to setup LAMP server to run our website/application.

Using .pem file we can access our server by IP and ec2-user (default user) for Amazon linux and ubuntu if you have install ubuntu system. You need to convert your .pem file to .ppk file is you are using putty to connect your server.

Once you connect your server you need to run following command to update linux.

sudo yum update -y

And follow this link for LAMP setup.

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html

Share your thoughts with us. Tweet us at @LetsNurture.

Want to work with us? We're hiring!
  • Rajendra

    Nice read. Thanks for very detailed article. Apart from that, I would also like to know how to use Loadbalancer for the multiple instances.