<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: MingJin Lu</title>
    <description>The latest articles on DEV Community by MingJin Lu (@kch3coo).</description>
    <link>https://dev.to/kch3coo</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F772305%2Fd98869db-8d97-4111-ada2-147ef7b0389f.png</url>
      <title>DEV Community: MingJin Lu</title>
      <link>https://dev.to/kch3coo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kch3coo"/>
    <language>en</language>
    <item>
      <title>Create a running ec2 Linux instance for Free</title>
      <dc:creator>MingJin Lu</dc:creator>
      <pubDate>Fri, 10 Dec 2021 23:42:34 +0000</pubDate>
      <link>https://dev.to/kch3coo/create-a-running-ec2-linux-instance-for-free-182c</link>
      <guid>https://dev.to/kch3coo/create-a-running-ec2-linux-instance-for-free-182c</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;Learning how to use cloud servers and utilizing cloud computing is one of the must-have skills in current-day software development. There are plenty of options when it comes to cloud service providers, for example, Heroku, Google Cloud and Amazon Web Services etc. Today, I am going to show how to spin up a cloud server on AWS, one of the most popular options and is used by many software companies.&lt;/p&gt;

&lt;p&gt;First of all, AWS is very complicated and it has many tools that you will never need to use. For the purpose of just hosting a cloud server, we are going to focus on the tool AWS EC2.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prerequisite: Make sure you already have an AWS account (duh)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Launch a EC2 Linux Instance
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step1&lt;/strong&gt;: Login to AWS and search EC2 and create an instance&lt;/p&gt;

&lt;p&gt;Once you logged in to AWS, you are very likely to get lost from all of its options and components. No worries, just search for EC2 and select "Launch instance". An instance is a virtual server, or you can think of it as a computer that is running constantly.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GJiFwka2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hl85qmux5xhtsxqrxjty.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GJiFwka2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hl85qmux5xhtsxqrxjty.png" alt="Create EC2 instance" width="880" height="709"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Step2&lt;/strong&gt;: Use the default setting, it is free&lt;/p&gt;

&lt;p&gt;AWS provides a free option for us to use, and it is best for small and personal applications. It is sufficient for building your own websites, school projects, experimental applications and custom APIs.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7qvAMXzu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4g4b7sxj8ptgnns1ez4o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7qvAMXzu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4g4b7sxj8ptgnns1ez4o.png" alt="Select instance type" width="880" height="760"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Step3&lt;/strong&gt;: Press Next until you reach Configure Security Group&lt;/p&gt;

&lt;p&gt;There is a bunch of selections and settings you can choose from. Just leave it as it is for the most part unless you are an expert and you know exactly what to do.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bppHFdXW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jtsk3nsjuym7mxjjaoxr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bppHFdXW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jtsk3nsjuym7mxjjaoxr.png" alt="Press next" width="880" height="761"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uvTLhszJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cbrpi10ckxn2zkmgi3kp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uvTLhszJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cbrpi10ckxn2zkmgi3kp.png" alt="Configure Security Group" width="880" height="758"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Step4&lt;/strong&gt;: Add a new TCP rule that points to your app.&lt;/p&gt;

&lt;p&gt;Now, this is a setting that you need to know. If your node js runs on 8080, configure a TCP protocol so that it is on 8080. This allows other computers to connect to your server via this port. Also, if you are hosting a website, make sure to configure an HTTP port 80 so that people can visit the website that is hosted on this server. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qH6Dhncj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7tz3phhcrqq1eycfk81o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qH6Dhncj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7tz3phhcrqq1eycfk81o.png" alt="Add TCP rules" width="880" height="760"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--q1YLQnvI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fx3vbgehyzi3a2n1eg3t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--q1YLQnvI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fx3vbgehyzi3a2n1eg3t.png" alt="TCP rules example" width="811" height="174"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Step5&lt;/strong&gt;: Select an existing key pair or create a new key pair.&lt;/p&gt;

&lt;p&gt;This is the step where you create your pem file. Remember to store it somewhere save! You will use this to SSH into your server and make all the magic happen! You can also use existing key pairs so you don't have to switch keys when you SSH into your frontend server and backend server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ucjE3bmR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zxvffwtjo6cal4nkbb7w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ucjE3bmR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zxvffwtjo6cal4nkbb7w.png" alt="Select Key Pairs" width="701" height="562"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Step6&lt;/strong&gt;: Review and launch your instance!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b8bS7_v_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/obg3p48y75j47zsavgb3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b8bS7_v_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/obg3p48y75j47zsavgb3.png" alt="Review and launch your instance" width="880" height="762"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  SSH into Your Running Instance
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step1&lt;/strong&gt;: Rename the server.&lt;/p&gt;

&lt;p&gt;Now you have your instance created, you can go onto EC2 and find your instance. You can rename it so you remember what this server is used for. Very important if you have multiple instances running.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZHfHT-Wj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j5x3u3f0gya7i5wcazs4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZHfHT-Wj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j5x3u3f0gya7i5wcazs4.png" alt="Rename Server" width="880" height="380"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Step2&lt;/strong&gt;: Get ssh info for instance&lt;/p&gt;

&lt;p&gt;Click on to instance ID and get more info about this server&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U7LRVbEu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/be0ypjf4kr4fs3suknma.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U7LRVbEu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/be0ypjf4kr4fs3suknma.png" alt="Get instance info" width="880" height="247"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click Connect&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S67vK-kP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5gg26iwhxarc2gqs9hcl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S67vK-kP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5gg26iwhxarc2gqs9hcl.png" alt="Connect to instance" width="880" height="568"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy SSH info&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uyYi7oI---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gogmfof32u8wzoyb8dsn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uyYi7oI---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gogmfof32u8wzoyb8dsn.png" alt="Copy SSH info" width="811" height="588"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Step3&lt;/strong&gt;: Open a terminal and ready to connect&lt;/p&gt;

&lt;p&gt;I am using an ubuntu terminal, which uses Linux commands. Some commands might be different for other terminals.&lt;/p&gt;

&lt;p&gt;Open up a terminal and go to the folder where you stored your pem file.&lt;/p&gt;

&lt;p&gt;Move the file to .ssh by running. You can also use cp to copy it to ~/.ssh&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mv OmnifyBackendServer.pem  ~/.ssh/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Step4&lt;/strong&gt;:  Modify key permission&lt;/p&gt;

&lt;p&gt;Since SSH uses this key, we need to modify the key permission for safety reasons. Most importantly your terminal is going to YELL at you if you don't do this.&lt;br&gt;
Change the permission of the pem file by using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod 400 ~/.ssh/filename.pem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rHV1MHWP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4erm3vh6h71cp8dtvafz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rHV1MHWP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4erm3vh6h71cp8dtvafz.png" alt="change pem file permission" width="760" height="53"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Step5&lt;/strong&gt;:  Connect:&lt;/p&gt;

&lt;p&gt;Connect to the running instance using the command you copied from EC2, you might have to modify it so that it points to the correct pem file location. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -i "~/.ssh/OmnifyBackendServer.pem" ec2-user@ec0-00-000-74-34.us-east-2.compute.amazonaws.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0Xmng3RK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gzar550yxin0zmxjudto.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0Xmng3RK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gzar550yxin0zmxjudto.png" alt="Connect successfully" width="880" height="211"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;That's it, you have created your first AWS EC2 instance and you know how to access it. The next step is to configure it so that it runs your application. You can install git to pull your code and install all the dependency that is needed. Then, you have to configure your instance to run your application in the background. Some common tools to use are systemctl, PM2, and Nginx. There are plenty of ways to play around with your instance, and I hope you have fun and enjoy reading this article!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>devops</category>
      <category>linux</category>
    </item>
  </channel>
</rss>
