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
- Connect to your Linux instance as
ec2-user
using SSH - Run command : sudo yum install -y gcc-c++ make
- Run command : curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash –
- Run command : sudo yum install -y nodejs
- Run command : sudo yum install -y git
- Run command : sudo yum install -y pm2
- Run command : Git clone url
- Run command : Npm i
- 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