Install And Setup MERN Stack On CentOS,Fedora & RedHat

Exported on 25-Sep-2021 14:50:10

Installs MERN Stack Development Server on RHEL Based Systems.

This Blueprint Installs MERN Stack development server on a RHEL Based Systems.

MERN stands for MongoDB, ExpressJS, ReactJS and Nginx web server. This blueprint install all these components on the target system and launches a react development server.

MongoDB MongoDB is a source-available cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas.

Express Express.js, or simply Express, is a back end web application framework for Node.js, released as free and open-source software under the MIT License. It is designed for building web applications and APIs.

ReactJS React is a free and open-source front-end JavaScript library for building user interfaces or UI components. It is maintained by Facebook and a community of individual developers and companies.

Nginx NginX, is a web server that can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache. The software was created by Igor Sysoev and publicly released in 2004. Nginx is free and open-source software.

Pre-Blueprint Attune setup
  1. On the Inputs tab, create a Linux node for the host you wish to install the stack on.
  2. On the Inputs tab, create Linux credentials to connect to the host you wish to install the stack on.
Blueprint Steps
  1. Install NodeJS and NPM for dependency management.
  2. Configure MongoDB NoSQL Database.
  3. Install Express.js - a NodeJS framework to build web applications faster.
  4. Install and configure a ReactJS project.

Parameters

Name Type Script Reference Default Value Comment
s1 Linux / Unix Server s1
s1c Linux OS Credential s1c

1 - Install Node.js and NPM

Updates yum package list, downloads installer for Node.js 12.x and runs it to install Node.js

The connection details have changed from the last step.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Update package list
sudo yum -y update

# Download setup script
sudo curl -fsSL https://rpm.nodesource.com/setup_12.x -o nodesource.sh

# Configure install script
sudo bash nodesource.sh

# Start installation 
sudo yum install -y nodejs

2 - Upload MongoDB repo config

Uploads repository for the MongoDB server.

Login as user on node

Connect via SSH
ssh user@hostname
Deploy archive mongodb-org-4.4.repo.zip to remote path uploads
  1. Locate Files archive "mongodb-org-4.4.repo.zip", This can be downloaded from Attune
  2. Copy the Files archive to the server
  3. Extract the root of the Files archive to uploads, relative to the home directory
  4. Check that the files are in the correct location

3 - Install MongoDB Server

Installs MongoDB server.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Move MongoDB repo file
sudo mv uploads/mongodb-org-4.4.repo /etc/yum.repos.d/mongodb-org-4.4.repo

# Install MongoDB
sudo yum install -y mongodb-org

4 - Install Express.js Framework

Installs Express.js - Fast, unopinionated, minimalist web framework for Node.js.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
sudo npm i -g express

5 - Install React Development Environment

Install React.js, creates a React project and launches the React development server.

5.1 - Update apt repositories

Update apt packages.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Install APT update
sudo yum -y update

5.2 - Install Node & NPM

This installs Node.js server into the target machine.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Download setup script
sudo curl -fsSL https://rpm.nodesource.com/setup_12.x -o nodesource.sh

# Configure install script
sudo bash nodesource.sh

# Start installation 
sudo yum install -y nodejs

5.3 - Create React App

Creates a basic React application.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Scaffold a react project
npx create-react-app myfirstreactapp

5.4 - Start React Development Server

Starts the react development server in background.

To access the running server process, use the command: screen -x

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Change working directory
cd myfirstreactapp

# Install screen package
sudo yum -y install screen

# Configure screen to run in background
sudo echo "zombie xy" >> ~/.screenrc

# Start development server
screen -d -m npm start