GithubHelp home page GithubHelp logo

aws-ec2-easysetup's Introduction

AWS-EC2-EasySetup

Launch a server on Amazon Web Services EC2 (Elastic Compute Cloud)

This repo is under construction. Please visit again!

What is AWS EC2? AWS EC2 is a service Amazon provides allowing developers to create, launch, and terminate server-instances as needed and pay only for active server usage time.

First we'll launch the instance then we'll build the server.

  1. First log in to Amazon AWS. Login is nested in the "My Account" Menu. (Image)
  2. Check and set your location in upper right corner to the one nearest to you.
  3. Open the EC2 Dashboard
  4. Select Running Instances
  5. Select Launch Instance
  6. Choose an OS - I chose Ubuntu 14.04 which is free-tier eligible
  7. Keep all defaults until Step 6 (Go to next, next, next until then)
  8. Step 6: Configure New Security Group - this is the first real setup you'll be doing by hand. (Image)
  9. Name and Describe the Security Group - Name it anything a firewall should be called :)
  10. Review and modify your rules for access and ports:
  • http (Keep this, it will appear by default)
  • https (Keep this, it will appear by default)
  • 8080 - Add this port sometimes used by websites.
  • 9000 - Add this is for test and setup purposes.
  • SSH - (Keep this, it will appear by default) - you'll use this to talk to your server like any other SSH.
  1. Set the source access for EACH PORT to “Anywhere”
  2. Click Review and Launch.
  3. Create a new key pair
  • Name it
  • Save it in a safe place on your computer
  • Make note of the directory to which you're saving this private key!
  1. Once saved, launch the instance.
  • It will take awhile to build.
  • To look at progress, you can check out the EC2 Dashboard

Use the command line to access the new cloud server and program its output. For programming the server, I used Node.js We'll need to install Node, install any packages we'd like to run, and then write the code to build our server.

  1. In terminal, CD into the directory holding your new private key - cd [directory]
  2. Initiate a secure connection with your ubuntu instance: - ssh -i ubuntu@public-DNS-for-the-EC2-instance-you-just-launched
  • The public DNS can be found at the bottom right corner of your EC2 Dashboard.
  1. If this command is denied, you need to modify permissions for the pem (key) file. (Aside at the end of this document.)

  2. Now reattempt to ssh -i to the ubuntu instance.

  3. Now that we’re logged into the instance, make sure its packages are updated. …[fill]

  4. Create a directory for this new file

  5. CD into this newly unpacked directory

  6. Run binary for this file, then make it and install it. - ./configure && make && sudo make install node

  7. Node installs itself on the ubuntu instance. Now it's time to write your server file.

  8. Here is the one I am using: [add]

  9. Continuously run node makeServer.js, and put it in the background - nohup node makeServer.js &

  10. At any time you can kill this background task with kill [process#]

  11. Additionally, note that you can see all background processes with the script ps -ef will let me

  12. OK visit public-DNS-for-the-EC2-instance-you-just-launched - page should be live but why don't you see it?

  13. Add onto the url a colon and the port number you provided in the server file (eg. :9000)

We want to run it at port 80, the default http port. But we don’t want to have to sudo and use password as usual for this.

  1. sudo npm install express
  2. Create a new directory and a new js file inside to run an express server.
  3. Kill old process kill [process#]
  4. Write an express server. Here is the one I am using. [add]
  5. Instead of changing the port to 80 and making our administrative privledges vulnerable we'll use IP Tables. This will reroute incoming port 80 http traffic to port 9000.
  • sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 9000 Now run the expressServer.js file again and even though it runs on port 9000, it also redirects to 80.
  1. Run nohup again to make this process continuous! nohup node [filename].js &

  2. Congratulate yourself! You have a running instance pushing your server code out all the time!


####Aside: Modifying permissions for the pem file.

  1. Review current directory alongside permissions information - ls -l
  2. Disable the Group membership and add access for owner to read/write only eg. : Owner Group Everyone [RW-] [---] [---] chmod 600 [Filename]

aws-ec2-easysetup's People

Contributors

dhimalo avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.