Installing MongoDB, REDIS, NGINX, NVM, Node, PM2 and GIT in Amazon Linux AMI(EC2 Instance)

Prasanth C
2 min readDec 15, 2021

I was setting up an Amazon Linux AMI EC2 instance for backend development using Node.js, I had trouble finding the installation steps from the various sources. Here, I just collated the information, simplified the steps, and published it. Thinking this will save someone’s time.

Installed softwares:

1. MongoDB
2. REDIS
3. NGINX
4. NVM
5. NODE
6. PM2
7. GIT

Log into EC2 instance. We will start with updating the system first.
sudo yum -y update

1. MongoDB Installation

Create a /etc/yum.repos.d/mongodb-org-3.6.repo file so that you can install MongoDB directly, using yum.

For MongoDB 3.6

Use the following repository file:

[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

To install the latest stable version of MongoDB, issue the following command:
sudo yum install -y mongodb-org

To Start:
sudo service mongod start

To autostart on instance reboot:
sudo chkconfig mongod on

To Stop:
sudo service mongod stop

To Restart:
sudo service mongod restart

To check mongo connected or to use mongo shell
mongo

2. REDIS Installation

To compile install GCC:
sudo yum -y install gcc make

Download the latest stable release tarball from Redis.io.
wget http://download.redis.io/releases/redis-stable.tar.gz

Untar it and switch into that directory:
tar xzf redis-stable.tar.gz
cd redis-stable

Proceed to with the make command:
make

Install TCL
sudo yum install -y tcl

Run the recommended make test:
make test

Finish up by running make install, which installs the program system-wide.
sudo make install

To run as a background daemon:
To access the script move into the utils directory:
cd utils

From there, run the Ubuntu/Debian install script:
sudo ./install_server.sh

As the script runs, you can choose the default options by pressing enter. Once the script completes, the redis-server will be running in the background.

To Start REDIS:
sudo service redis_6379 start

To Stop REDIS:
sudo service redis_6379 stop

To check REDIS connected:
redis-cli ping

To access REDIS:
redis-cli

3. NGINX Installation

To install:
sudo yum install nginx

To Start:
sudo service nginx start

To autostart on instance reboot:
sudo chkconfig nginx on

To check:
Access the given ip in browser in 80 port

4. NVM Installation: (NVM is a Node Version manager)

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

To check installation:
nvm --version

5. Node Installation

nvm install node

To check installation:
node -v

6. PM2 Installation

npm install pm2 -g

To check installation:
pm2 -v

7. GIT Installation

sudo yum install git

To check Installation
git --version

Thinking to create a script to automate these installations, will share if I can complete it.

If you think, this saved your time, then spend time enjoying nature…

¯\_(ツ)_/¯

--

--