<?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>Forem: Sunil More</title>
    <description>The latest articles on Forem by Sunil More (@sunilmore690).</description>
    <link>https://forem.com/sunilmore690</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%2F173516%2F2c30674d-5bd5-46c3-b537-fb3594dcd467.png</url>
      <title>Forem: Sunil More</title>
      <link>https://forem.com/sunilmore690</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sunilmore690"/>
    <language>en</language>
    <item>
      <title>Store and Run your Javascript Online - tryjs.online</title>
      <dc:creator>Sunil More</dc:creator>
      <pubDate>Wed, 20 Mar 2024 08:28:23 +0000</pubDate>
      <link>https://forem.com/sunilmore690/store-and-run-your-javascript-online-tryjsonline-1400</link>
      <guid>https://forem.com/sunilmore690/store-and-run-your-javascript-online-tryjsonline-1400</guid>
      <description>&lt;p&gt;Calling all JavaScript enthusiasts! Are you tired of cumbersome setups and local environments just to experiment with your code? Look no further than TryJS.online, a brand new web application designed to streamline your JavaScript workflow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tryjs.online" rel="noopener noreferrer"&gt;Tryjs Online now&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;What is TryJS.online?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;TryJS.online is an online platform that allows you to store, run, and share your JavaScript code with ease. Simply head over to the TryJS.online website and you'll be greeted with a clean, intuitive interface perfect for jotting down your code snippets or pasting existing projects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features of TryJS.online&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Effortless Code Storage: No more scrambling to find local files. TryJS.online lets you save your JavaScript code directly on the platform, accessible from any device with an internet connection.&lt;br&gt;
Instant Code Execution: Gone are the days of complex setups. With TryJS.online, you can run your code with a single click. See the results come to life in the built-in console, helping you debug and iterate efficiently.&lt;/p&gt;

&lt;p&gt;Sharing Made Simple: Collaboration is key! TryJS.online allows you to share your code with others with a simple link. This makes it perfect for showcasing your work, getting feedback, or working on projects together.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits of Using TryJS.online&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Enhanced Productivity: Save time and effort with TryJS.online's straightforward approach. Focus on writing great code, not managing local environments.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Improved Learning: TryJS.online is a fantastic tool for learning JavaScript. Experiment with different concepts and see the results in real-time, solidifying your understanding.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Seamless Collaboration: Work together seamlessly with TryJS.online's sharing functionalities. Perfect for team projects, code reviews, or brainstorming sessions.&lt;br&gt;
Who is TryJS.online For?&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;TryJS.online caters to a wide range of users:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript Beginners: Get your feet wet with JavaScript in a safe, sandboxed environment. TryJS.online eliminates the initial setup hurdles, allowing you to focus on the fundamentals.&lt;/li&gt;
&lt;li&gt;Experienced Developers: Streamline your workflow with TryJS.online. Quickly prototype ideas, test code snippets, or troubleshoot issues without setting up a local environment.&lt;/li&gt;
&lt;li&gt;Educators and Students: TryJS.online is an excellent platform for teaching and learning JavaScript. Educators can create interactive lessons and students can practice their coding skills in a collaborative environment.
Get Started with TryJS.online Today!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Head over to TryJS.online and experience the future of JavaScript development. With its intuitive interface and powerful features, TryJS.online is sure to become your go-to platform for all things JavaScript!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://runjavascript.in/" rel="noopener noreferrer"&gt;https://runjavascript.in/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>editor</category>
    </item>
    <item>
      <title>Complete Setup for Deploying Nodejs App with mongodb database on Amazon ec2</title>
      <dc:creator>Sunil More</dc:creator>
      <pubDate>Fri, 31 May 2019 16:15:05 +0000</pubDate>
      <link>https://forem.com/sunilmore690/complete-setup-for-deploying-nodejs-app-with-mongodb-database-on-amazon-ec2-3plj</link>
      <guid>https://forem.com/sunilmore690/complete-setup-for-deploying-nodejs-app-with-mongodb-database-on-amazon-ec2-3plj</guid>
      <description>&lt;h3&gt;
  
  
  Intro
&lt;/h3&gt;

&lt;p&gt;There are many ways to run the server and there are plenty of cloud platform option available in the market. But most famous cloud platform is  &lt;strong&gt;Amazon Ec2.&lt;/strong&gt;  So this article intends to give full guidance to setup NodeJs App(eg. ExpressJs) on Amazon EC2.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;These are the steps&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Launch a new ec2 instance from  &lt;a href="https://aws.amazon.com/" rel="noopener noreferrer"&gt;Amazon Web Service.&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; Setup SSH Connection to connect ec2 instance&lt;/li&gt;
&lt;li&gt; Install Nodejs using  &lt;a href="https://github.com/creationix/nvm" rel="noopener noreferrer"&gt;&lt;strong&gt;nvm&lt;/strong&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; Install MongoDB database&lt;/li&gt;
&lt;li&gt; Setup Nodejs (Express) App&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 1 # create a new ec2 instance from  &lt;a href="https://aws.amazon.com/" rel="noopener noreferrer"&gt;Amazon Web Service.&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;To create a new instance, you should have an active account on AWS.After logging to Aws&lt;/p&gt;

&lt;p&gt;select an ec2 option from Services&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flatnwr54pm8hj22qqvuo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flatnwr54pm8hj22qqvuo.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then click on  &lt;strong&gt;Launch Instance&lt;/strong&gt; button after that you’ll land to below page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foqewqcs25i1hu7bkqlia.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foqewqcs25i1hu7bkqlia.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then select one image from list of options. Please select an image according to your requirement and whichever is suitable for you. So in my case I’ll select Amazon Linux.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; After that maybe some installation command not work if you select an image other than Amazon Linux ,Centos.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next&lt;/strong&gt; Choose instance type, Let’s choose &lt;strong&gt;&lt;em&gt;t2.micro&lt;/em&gt;&lt;/strong&gt; which is eligible for the &lt;a href="https://aws.amazon.com/free/" rel="noopener noreferrer"&gt;free tier&lt;/a&gt;, so if your account is less than 12 months old you can run your server for free. Thanks to Amazon!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwat2u97hxsmulqb7768b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwat2u97hxsmulqb7768b.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next&lt;/strong&gt; Configure instance details, this is more complicated step but we can ignore this for now.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flvbv7lsqpy4uahukm487.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flvbv7lsqpy4uahukm487.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next&lt;/strong&gt; Add storage, Default size is 8 Gb but you can update size according to your requirement , but for now 8gb is enough&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdz0kbdwin1qsy2u09uca.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdz0kbdwin1qsy2u09uca.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next&lt;/strong&gt; Add Tags, add key-value pair for instance, but for now we’ll skip this step .Tags is useful if you more instance it’s better to search by Tag&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next&lt;/strong&gt; Configure Security Group,In my opinion this steps is more important ,Where we inbound(expose our server port) and outbound(restrict to access other server)&lt;/p&gt;

&lt;p&gt;In our case , to connect ec2 instance wee need open  &lt;strong&gt;ssh&lt;/strong&gt;  port 22 and to access our site publicly we need expose  &lt;strong&gt;http&lt;/strong&gt;  port 80 (when you visit any website by default it connect to port 80 )with selecting option  &lt;strong&gt;anywhere&lt;/strong&gt; for source&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inbound and Outbond Source&lt;/strong&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Anywhere&lt;/strong&gt; from anywhere we can access this port
&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Custom&lt;/strong&gt; only provided IP access this port
&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;My IP&lt;/strong&gt; only access this port within same server&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But you can expose any port according to your requirement , such as for  &lt;strong&gt;ftp&lt;/strong&gt; open port 21, for  &lt;strong&gt;https&lt;/strong&gt;  open port 443&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffdhsiq14xt5idmjhupo7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffdhsiq14xt5idmjhupo7.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next&lt;/strong&gt; Click review and launch, then you’ll see options selected in all steps&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fopgvdxdpct9zcz4x8vvi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fopgvdxdpct9zcz4x8vvi.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next&lt;/strong&gt; Click on Launch, then it’ll ask to create new key pair , which will used to connect our server using ssh with this key.&lt;/p&gt;

&lt;p&gt;Download this key pair, and click on Launch&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fipboe6ujnau91ah7a87l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fipboe6ujnau91ah7a87l.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2# Setup ssh connection to connect EC2 instance
&lt;/h3&gt;

&lt;p&gt;After creating instance , Go to that instance. In this page there is  &lt;strong&gt;connect&lt;/strong&gt; button click on that connect button then you’ll see this modal&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv5nwi2oos1d9fsbleqvv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv5nwi2oos1d9fsbleqvv.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So follow the steps which you’ll see when you open a modal.&lt;/p&gt;

&lt;p&gt;Steps :&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;gt; chmod 400 &amp;lt;pem file path&amp;gt;  
&amp;gt; ssh -i &amp;lt;pem file path&amp;gt; &amp;lt;user&amp;gt;@&amp;lt;public DNS&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;eg. ssh -i "sunilaws.pem" &lt;a href="mailto:ec2-user@ec2-54-218-8-133.us-west-2.compute.amazonaws.com"&gt;ec2-user@ec2-54-218-8-133.us-west-2.compute.amazonaws.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; In my case, user for my ec2 server is  &lt;strong&gt;ec2-user&lt;/strong&gt; because I’ve selected  &lt;strong&gt;Amazon Linux Image&lt;/strong&gt;.So In your case user will be different if you have selected an Amazon Machine Image other than  &lt;strong&gt;Amazon Linux&lt;/strong&gt;. Here is the list of al default user for Amazon Image .  &lt;a href="https://alestic.com/2014/01/ec2-ssh-username/" rel="noopener noreferrer"&gt;See here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3# Install Node Js on ec2 instance
&lt;/h3&gt;

&lt;p&gt;To set up Node.js on your Linux instance&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Connect to your Linux instance as  &lt;code&gt;ec2-user&lt;/code&gt;  using SSH.&lt;/li&gt;
&lt;li&gt; Install the current version of node version manager (nvm) by typing the following at the command line to install version 33.8.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;curl -o- [https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh](https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh) | bash&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We will use nvm to install Node.js because nvm can install multiple versions of Node.js and allow you to switch between them. See the  &lt;a href="https://github.com/creationix/nvm" rel="noopener noreferrer"&gt;nvm repo on GitHub&lt;/a&gt;for the current version to install.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Activate nvm by typing the following at the command line.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;. ~/.nvm/nvm.sh&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use nvm to install the version of Node.js you intend to use by typing the following at the command line.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;nvm install 7.9.0&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Test that Node.js is installed and running correctly by typing the following at the command line.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;node -e "console.log('Running Node.js ' + process.version)"&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This should display the following message that confirms the installed version of Node.js running.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Running Node.js v7.9.0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For more info, click on this  &lt;a href="https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html" rel="noopener noreferrer"&gt;link&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4# Install Mongodb on ec2 instance
&lt;/h3&gt;

&lt;p&gt;We’ve selected  &lt;strong&gt;Amazon Image ,&lt;/strong&gt; we’ll install mongodb using  &lt;strong&gt;yum&lt;/strong&gt; command&lt;/p&gt;

&lt;p&gt;Steps :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Configure the package management System(yum)&lt;/strong&gt;
Create a  &lt;code&gt;/etc/yum.repos.d/mongodb-org-3.6.repo&lt;/code&gt;  file so that you can install MongoDB directly, using  &lt;code&gt;yum&lt;/code&gt;.
Use the following repository file:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

**[mongodb-org-3.6]**  
name=MongoDB Repository  
baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.6/x86_64/  
gpgcheck=1  
enabled=1  
gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Install the mongodb package&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo yum install -y mongodb-org&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Start mongodb server&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo service mongod start&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Check mongodb server started by running below command&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mongo&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For more info , Please got to this  &lt;a href="https://docs.mongodb.com/manual/tutorial/install-mongodb-on-amazon/" rel="noopener noreferrer"&gt;link&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5 # Setup up Nodejs App(Express)
&lt;/h3&gt;

&lt;p&gt;In this step, we’re going to setup a new sample express app with mongodb connection using  &lt;a href="https://www.npmjs.com/package/mongodb" rel="noopener noreferrer"&gt;&lt;strong&gt;mongodb&lt;/strong&gt;&lt;/a&gt;  client library*&lt;em&gt;.&lt;br&gt;&lt;br&gt;
**According to your requirement, you can use any mongo library available in npm, such as  &lt;a href="https://www.npmjs.com/package/mongoose" rel="noopener noreferrer"&gt;&lt;strong&gt;mongoose&lt;/strong&gt;&lt;/a&gt;&lt;/em&gt;&lt;em&gt;,&lt;/em&gt;&lt;em&gt;[&lt;/em&gt;&lt;em&gt;mongojs&lt;/em&gt;*](&lt;a href="https://www.npmjs.com/package/mongojs" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/mongojs&lt;/a&gt;)  etc.&lt;/p&gt;

&lt;p&gt;First connect to your ec2 instance using command provided in Step 1&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ssh -i &amp;lt;pem file path&amp;gt; &amp;lt;user&amp;gt;@&amp;lt;public DNS&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

mkdir SampleExpressApp  
npm init


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Create new file  &lt;em&gt;app.js with following code&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

var express = require("express");  
var app = express();  
var MongoClient = require("mongodb").MongoClient;  

app.get("/", function(req, res) {  
  res.send("Hello World!");  
});  

app.get("/users", function() {  
  MongoClient.connect("mongodb://localhost:27017/test", function(err, db) {  
    if (err) next  
    db  
      .collection("users")  
      .find()  
      .toArray(function(err, result) {  
        if (err) throw err;  

        res.json(result)  
      });  
  });  
});

app.listen(3000,function(){  
    console.log('Express app start on port 3000')  
});


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Then install mongodb &amp;amp; express dependancy&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

npm install mongodb --save  
npm install express --save


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Then start server&lt;/p&gt;

&lt;p&gt;&lt;code&gt;node app.js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now Express App start on port 3000&lt;/p&gt;

&lt;p&gt;Then open below url in browser&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://&amp;lt;your public DNS&amp;gt;:3000&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;But if you close this terminal or if you perform Ctrl+C server will stop.&lt;/p&gt;

&lt;p&gt;So to start server in the background there are multiple NPM library but we’ll use  &lt;strong&gt;forever&lt;/strong&gt; to start server. Here is the different option&lt;br&gt;&lt;br&gt;
&lt;a href="https://expressjs.com/en/advanced/pm.html" rel="noopener noreferrer"&gt;https://expressjs.com/en/advanced/pm.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install forever globally using npm&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install -g forever&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Start server using forever&lt;/p&gt;

&lt;p&gt;&lt;code&gt;forever start app.js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To see list of forever process&lt;/p&gt;

&lt;p&gt;&lt;code&gt;forever list&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftf7imk4mf9af7jllv2nc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftf7imk4mf9af7jllv2nc.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To see Express Server logs&lt;/p&gt;

&lt;p&gt;&lt;code&gt;tail -f &amp;lt;logfile path&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you want to store logs in predefined file, then start server with following command&lt;/p&gt;

&lt;p&gt;&lt;code&gt;forever start app.js -l /path/to/log/file&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To access this server publicly, you’ve to open port 3000 from security group by adding into inbound rule, as we open port in  &lt;strong&gt;Step1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After opening 3000 port publicly , hit below url&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://&amp;lt;your pblic DNs&amp;gt;:3000&lt;/code&gt;&lt;br&gt;
eg. http:&lt;strong&gt;//ec2-0-0-0-0.us-west-2.compute.amazonaws.com:3000&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But To access your app on public domain (port 80) you’ve to forward port 80 to 3000.&lt;/p&gt;

&lt;p&gt;We’ve 2 way to forward port 3000 to 80, you can choose any one. But I’ll prefer to to select option of nginx&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; iptables&lt;/li&gt;
&lt;li&gt; nginx&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;iptables&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPTiptables -A INPUT -i eth0 -p tcp --dport 3000 -j ACCEPTiptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;nginx&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Install nginx&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo yum install nginx -y

Start nginx Server

sudo service nginx start


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To see nginx started , Enter your public DNS URL in browser&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnecs7fz8uki80mikr0dc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnecs7fz8uki80mikr0dc.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next step , To forward port 3000 to 80&lt;/p&gt;

&lt;p&gt;Edit below nginx configuration file&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vi /etc/nginx/nginx.config&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And change below code&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

location / {  
    root html;  
    index index.html index.htm;  
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;with following one&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

location / {  
    proxy_set_header  X-Real-IP  $remote_addr;  
    proxy_set_header  Host       $http_host;  
    proxy_pass        [http://127.0.0.1:3000;](http://127.0.0.1:3000;/)  
  }


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Restart  &lt;strong&gt;&lt;em&gt;nginx&lt;/em&gt;&lt;/strong&gt;  for the new  config  to take effect.&lt;/p&gt;

&lt;p&gt;Now visit your server’s public DNS URL, It should show “&lt;strong&gt;hello word”&lt;/strong&gt; in response rather than nginx welcome page&lt;/p&gt;

&lt;p&gt;If still not working, then check nginx.config file including another configuration file&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>node</category>
      <category>aws</category>
    </item>
    <item>
      <title>Deploy Docker based project using github in 5 min with simple CI/CD integration</title>
      <dc:creator>Sunil More</dc:creator>
      <pubDate>Thu, 30 May 2019 08:32:19 +0000</pubDate>
      <link>https://forem.com/sunilmore690/deploy-docker-based-project-using-github-in-5-min-with-simple-ci-cd-integration-1n9n</link>
      <guid>https://forem.com/sunilmore690/deploy-docker-based-project-using-github-in-5-min-with-simple-ci-cd-integration-1n9n</guid>
      <description>&lt;p&gt;To Setup new project using docker approach, run following command on Ubuntu&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl https://s3-us-west-2.amazonaws.com/opt-scripts/project-setup.sh -o project-setup.sh &amp;amp;&amp;amp; bash project-setup.sh
Sample Github Repo: https://github.com/sunilmore690/expressjexample\
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;By running this script it’ll ask for below things&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gihub Project Name&lt;/strong&gt;: expressjexample&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Github Orgnization/User Name&lt;/strong&gt;: sunilmore690&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Git Branch&lt;/strong&gt;: master&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Github ACCESS TOKEN(Optional)&lt;/strong&gt;: For private github repo&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NODE_ENV&lt;/strong&gt;: staging/production&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;App port on which your server will run&lt;/strong&gt;: 3000&lt;/p&gt;

&lt;p&gt;Script perform the following operation&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install Docker &amp;amp; Docker-compose&lt;/li&gt;
&lt;li&gt;Install Git&lt;/li&gt;
&lt;li&gt;Clone the project&lt;/li&gt;
&lt;li&gt;Setup post-merge hooks &amp;amp; which will execute deployment.sh if there changes when you pull the code&lt;/li&gt;
&lt;li&gt;If NODE_ENV other than production, It’ll set up cron to execute git pull to get the latest code&lt;/li&gt;
&lt;li&gt;If deployment.sh not exist in your root dir of your project, It’ll create deployment.sh with the following snippet&lt;/li&gt;
&lt;li&gt;Setup NODE_ENV as env variable&lt;/li&gt;
&lt;li&gt;Deploy the project by executing, deployment.sh&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you’ve not added deployment.sh in root dir of your project then the script will create deployment.sh in your dir with the following snippet&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -t &amp;lt;Github Project Name&amp;gt;.

docker stop &amp;lt;Github Project Name&amp;gt;-container

docker rm &amp;lt;Github Project Name&amp;gt;-container

docker run — restart always -d — name &amp;lt;Github Project Name&amp;gt;-container — env NODE_ENV=&amp;lt;NODE_ENV&amp;gt; -p 80:&amp;lt;PORT&amp;gt; &amp;lt;Github Project Name&amp;gt;:latest
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Test a simple CI/CD integration&lt;/p&gt;

&lt;p&gt;If you’ve provided NODE_ENV other than production then you can push your code to provided GitHub branch and It’ll run deployment.sh within 5 min&lt;/p&gt;

&lt;p&gt;For NODE_ENV &amp;gt;&amp;gt; production, you’ve to manually pull the code and by pulling the code it’ll trigger deployment.sh&lt;/p&gt;

&lt;p&gt;The deployment log file (deployment.log) will be available in project home dir.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>github</category>
    </item>
  </channel>
</rss>
