HugeServer Knowledgebase

How to install MEAN Stack (MongoDB, Express.JS, Angular.JS, Node.JS) on CentOS 7

Introduction

MEAN.JS is a full JavaScript stack that contains MongoDB, Express.JS, Angular.JS, and Node.JS. This JavaScript framework accelerates the web application development using JavaScript as backend.
Using the MEAN Stack you can rapidly build easy-maintainable web applications based on JavaScript.

  • Node.js is a server-side JavaScript execution environment. It’s a platform built on Google Chrome’s V8 JavaScript runtime. It helps in building highly scalable and concurrent applications rapidly.
  • Express.js is lightweight framework used to build web applications in Node. It provides a number of features for building single and multi-page web applications.
  • MongoDB is a schemaless NoSQL database system. MongoDB saves data in binary JSON format which makes it easier to pass data between client and server.
  • Angular.js is a JavaScript framework developed by Google. It provides some awesome features like the two-way data binding. It’s a complete solution for rapid and awesome front-end development.

We are assuming that you have root permission, otherwise, you may start commands with “sudo”.

Install Dependencies

First of all, we have to install some dependencies in order to proceed,

yum install gcc-c++ make git fontconfig bzip2 libpng-devel ruby ruby-devel
gem install sass

Install MongoDB

In this section, we are going to install MongoDB as our Database, in order to install the latest stable version of MongoDB you should add the official repository first. create a new file with your text editor:

nano /etc/yum.repos.d/mongodb.repo

Paste the following lines in it then save and exit:

[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc

Now you can easily install MongoDB with the following command:

yum install mongodb-org

After the installation process is finished you can start and enable the MongoDB service with the commands below:

systemctl start mongod
systemctl enable mongod

Install NodeJS and NPM

In order to install Node.JS and NPM we have to add the “NodeSource” repository, the following bash script will do this easily:

curl -sL https://rpm.nodesource.com/setup_8.x | bash -

Now you can execute the command below to install Node.JS and NPM:

yum install nodejs

Check the installed versions:

node -v
v8.6.0
npm -v
5.3.0

Install Bower and Gulp

Bower is package management tool for client-side programming and it depends on NodeJS and NPM.
You can install Bower with this NPM command:

npm install -g bower

Gulp is a JavaScript task runner that can automate many tasks, you can install it with NPM command as well:

npm install -g gulp

For verifying that Bower and Gulp are installed successfully you can execute the following command:

npm list -g --depth=0

You should see something like below:


/usr/lib
├── bower@1.8.2
├── gulp@3.9.1
└── npm@5.3.0

Download and Install MEAN from GIT

Now we can download the latest version of MEAN which is “0.6.0” at the time of writing.
Execute the following command:

git clone https://github.com/meanjs/mean.git

Switch to the MEAN main directory:

cd mean

Install MEAN with the following command:

npm install

After the installation process is finished without errors you can execute the command below to install the front-end stuff:

bower install --allow-root

Start and Test

You can easily start your MEAN stack project with the following command:

npm start

It should run without any errors and you can look up your MEAN stack default page through the following address:

http://IP_Address_Or_Dmain:3000

You should see a page like below:

 
For more information about MEAN Stack you can check out the official website!

Was this tutorial helpful?

Thank you for your vote.Thank you for your vote.

Similar Posts

One thought on “How to install MEAN Stack (MongoDB, Express.JS, Angular.JS, Node.JS) on CentOS 7”

Leave a Reply

Your email address will not be published. Required fields are marked *

*