Skip to content

Instantly share code, notes, and snippets.

@hpphat92
Created September 27, 2017 07:09
Show Gist options
  • Save hpphat92/2bf6f060428f8f78f67118dbba36fd0b to your computer and use it in GitHub Desktop.
Save hpphat92/2bf6f060428f8f78f67118dbba36fd0b to your computer and use it in GitHub Desktop.
Guide to connect and deploy AWS Server

Guide to connect and deploy AWS Server

Preparation

  • PEM file containing private key from AWS server.
  • A domain to server
  • GIT Bash (In Window, can't use command line tool or powershell).

Steps:

Step 1: Connect to server:

  • In Window, open GIT Bash and run: ssh -i [Direction to PEM File] [using either root, ubuntu or ec2-user, centos]@[server domain]
  • For example ssh -i phatHong.pem ubuntu@ec2-52-53-185-37.us-west-1.compute.amazonaws.com

Reference Link

Connect is success in case your commandline changed to your remote server machine ip and name.

Step 2: Installing Stubs:

We need

  • node for environment.
  • npm for installing packages from your project.
  • git for version controlling (or pull push).
  • unzip for unzip compressed files (*.zip).
  • http-server for running server.
Step 2.1 (NO NEED) Install YUM (It is first thing to install)

Running Command: sudo apt-get install yum. To install YUM

TroubleShooting: In Case of error in above command. Run : sudo apt-get update

Step 2.2 Install NodeJS Latest version

Running following command in order

  • sudo apt-get purge nodejs npm
  • curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
  • sudo apt-get install -y nodejs

to install nodejs

Step 2.3 Verify that nodejs is installed correctly
2.3.1 Run node -v to verify that node is installed
2.3.2 In case of it throw error or not return the current node version. We check command: nodejs -v.
2.3.3 If nodejs -v return node version. we need to map nodejs to node. If not, we have to reinstall node again.
2.3.4 To Map nodejs to node, we run the following command: sudo ln -s /usr/bin/nodejs /usr/bin/node
2.3.5 Rerun node - v to verify that it is ok now.:smile:
Step 2.4 Install npm, git, unzip

Run commands:

sudo apt-get install git

sudo apt-get install npm

sudo apt-get install unzip

npm i http-server -g

Step 3: Upload local file

Step 3.1: Create a new folder to contain our project files
Step 3.2: zip whole current project in your local machine
Step 3.3: We run: scp -i [local file PEM] [Directory to local zip file] [using either root, ubuntu or ec2-user, centos]@[server domain]:[Directory to folder on server]
Step 3.4: Unzip file on server using command: unzip [Directory to file].

Step 4: Install and run

Step 4.1: Go to folder of code, run npm install to install packages.
Step 4.2: Run http-server -p [PORT VALUE]

Keep that running and enjoy by going to domain and check. ☺️

Reference Link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment