In this article we will highlight what is a mean stack and how to install and setup MERN stack in Centos/Redhat
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.
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
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
sudo npm install -g create-react-app
cd app-name npm start