In this article we will highlight what is a mean stack and how to install and setup mean stack in Centos/Redhat
Table of Contents
What is the MEAN stack?
M in MERN stands for MongoDB. MongoDB is a simple NoSql and object-oriented database technology that is efficient and scalable for large data storage. MongoDB stores data as objects in JSON format, in separate documents instead of storing in rows and columns like in a typical relational database. This increases productivity in the manipulation and retrieval of data in abundance.
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.
A in mean stack stands for Angular. Angular is an MVC framework for the client end or front end. Angular allows us to create a strong interactive web or mobile application. It also has great support for creating cross-platform and progressive web applications.
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 Angular.
Once again take advantage of the simplicity npm provides and use it to run the following command to install angular cli.
npm install -g @angular/cli
When you have your angular cli installed, you can use the ‘ng’ package to create a new angular application to try your new installation.
ng new hello-angular cd hello-angular ng serve