BackendWeb Development

How to Install Nodejs in AWS EC2 in a proper way (PM2)

The installation of AWS Linux EC2 node server is a common task for many people. This tutorial will show you how to install and configure AWS Linux EC2 node server on your own.

This is a quick guide to installing and configuring EC2 instances on AWS. It covers all the steps needed to set up and run an instance of Linux on EC2.

This is a quick guide to installing and configuring Docker on AWS. It covers all the steps needed to set up and run Docker containers on AWS.

To Setup node.js in Linux  ec2 instance server installation

  1. Connect to your Linux instance as ec2-user using SSH
  2. Run command : sudo yum install -y gcc-c++ make
  3. Run command : curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash –
  4. Run command : sudo yum install -y nodejs
  5. Run command : sudo yum install -y git
  6. Run command : sudo yum install -y pm2
  7. Run command : Git clone url
  8. Run command : Npm i
  9. Run command : Sudo pm2 start npm –name “gyan” — start

systemd service

 

[Unit]
Description=gyaanapi
After=multi-user.target

[Service]
ExecStart=/usr/bin/node /home/ec2-user/gyaanapi/bin/www
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=YourAppName
User=ec2-user
EnvironmentFile=/home/ec2-user/gyaanapi/config/config.env

[Install]
WantedBy=multi-user.target
  • sudo systemctl enable YourAppName.service
  • sudo systemctl start YourAppName.service

Reference Link : https://www.sammeechward.com/deploy-node-app-on-aws-ec2-amazon-linux-2

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button