How to kick start aws account - 1

1. Sign up first
2. Add a payment method, 2rs will be deducted and your account will be on hold till Amazon validate the payment method with bank. Takes upto 24 hrs.
3. Once the payment is verified, you can delete the card associated. But before deleting you have to add another Valid card and make it default.
4. Go to ec2 console and create a "key pair". Name it such that your email address is in it.
5. 'pem' file will be downloaded after creation, save it.
6. Back to ec2 dashboard and create an instance (Ubuntu plain preferred). No need to change any other options if you are opting for free tier.
7. Launch the instance
8. Now, you can connect to it by it's public ip or domain name (you can find from view instances and clicking on the instance).

>>> ssh -i <private-file>.pem ubuntu@<public-ip/domain-name>


ssh -i <my-private-key>.pem ubuntu@54.184.27.227

Before that, you have to alter permission for pem file.

>>> chmod 400 <private-file>.pem

9. Buy a domain from Godaddy
10. Back to EC2 - Create an Elastic IP
11. Associate the Elastic IP created with the EC2 instance already launched (Go to Elastic Ips dashboard, select the created IP and click Actions -> Associate Address)
12. Update the A record from DNS management of Godaddy with the Elastic IP ONLY

Done

Making your EC2 instance ready.

1. scp -i myfile.pem ~/Desktop/apache-tomcat-7.0.72.zip ubuntu@ElasticIP:/home/ubuntu/


First change the public permissions of pem file.

a) chmod 600 file.pem

2. SSH -i <your-private-pem-file> ubuntu@ElasticIP

3. sudo apt-get install unzip

4. unzip apache-tomcat-7.0.72.zip

5. Install Java
    a) sudo add-apt-repository ppa:webupd8team/java
    b) sudo apt-get update
    c) sudo apt-get install oracle-java7-installer

5.  If above is not working, that's because recently Oracle has changed it's archives and it's not fixed it. Following the below procedure in that case,

Download the tar.gz (Java SE Development Kit)  from below location. http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html

SCP it to aws.

unzip the tar.gz file and update this folder location in catalina.sh file of tomcat as,

(tar xvf <jdk-sdk-file>.tar.gz)


JAVA_HOME='/home/ubuntu/javase_folder'

The above will set all to run the tomcat server.

6. chmod +x  apache-tomcat-7.0.72/bin/catalina.sh

7. sh apache-tomcat-7.0.72/bin/Startup.sh


Note: By default, tomcat runs in 8080, so to hit your public ip and see tomcat start page, you have to open the 8080 from custom protocol.

Goto the corresponding security group of the ec2 instance. You can find in the ec2 dashboard options, Click on it.

In the "Inbound", ADD a rule with below options.

Custom TCP Rule  -> TCP -> 8080  -> remaining default. Access should from "anywhere"


8) Now redirect 80 requests to a web service which is listening on 8080. For that

1. sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

9) You need to add 80 port in the security group inbound rule just like you did for 8080. This is to access the default 80 port.


Update: Java 8 link, https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html