In this article we will highlight what is a mean stack and how to install and setup MERN stack in Centos/Redhat
Table of Contents
What is the MERN stack?
E in MERN stack stands for express JS. Express js or express is a node js framework that promotes the rapid development of node-based web and mobile applications. Express supports the MVC framework which helps in building more scalable, structured and dynamic websites. Express focuses more on the back-end or the developer side.
R in MERN stands for React. MERN is similar to MEAN but uses React for the development of front-end web applications rather than using Angular. React is an open-source JavaScript library that allows us to make reusable components for a single-page user interface.
N in MERN stack stands for Node JS. Node JS allows out to write JavaScript on the server or outside of the browser. Node uses an event-driven, non-blocking I/O model that makes it lightweight and effectual, seamless for applications that run across distributed devices.
Step 1: update your centos/Redhat
yum -y update

Step 2: installing MongoDB
Create a file to install mongoDB using the package manager. Go to /etc/yum.repos.d/mongodb-org-4.2.repo
And open the file through
sudo vi /etc/yum.repos.d/mongodb-org-4.2.repo
once you are inside the file paste in the content to get mongoDB repository in your operating system
[mongodb-org-4.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc
save and exit.

Now you can simply run the following command to start the process of installation.
sudo yum install -y mongodb-org

Press ‘y‘ for the rest of your installation.
Once the process is completed you can start and enable your mongoDB
systemctl start mongod.service
systemctl enable mongod.service

you can check your newly installed mongoDB version by running
mongod --version

Step 3: installing node JS
First make sure you have curl installed, if not simply type this command to install it.
sudo yum install curl

now add source repository to your OS to add NodeJS repository.
curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -

once the node JS repository is added, run the following command to install Node JS
sudo yum install nodejs

You can check both node and npm version as in recent version npm is installed with node js
node –version
npm --version

you can install node JS built-in tools to ease up with using of addons of npm and node js. It’s optional you can skip this but its recommended.
yum install gcc-c++ openssl-devel make

Step 4: installing Express
Install express JS globally to access the express repository from your OS.
npm install -g express-generator

Once you have express installed you can create a directory and navigate in it to create a project.
mkdir projectName
cd projectName
express
npm install

step 5: installing React
Once you have your node JS and npm installed, then it would be left to just run a simple command.
sudo npm install -g create-react-app

you are installing it globally through ‘-g’.
When the installation is completed, you need to try creating a new project.
create-react-app app-name

this command will make certain you have all things installed in your folder that you need for a React site.
You can access your project by navigating in your directory “app-name”.
cd app-name
npm start