Top

How to install MEAN Stack on CentOS

Here we will install MEAN stack on CentOS 6.8.

To check your operating system’s version, connect your VPS (Virtual Private Server) with ssh and run this command on terminal:

“cat /etc/redhat-release”

This will print your operating system version.

Install NodeJS.

  1. Add node.js yum repository

First, we need to add yum repository of node.js to our system which is sourced from NodeJS’s official website. Run the following commands in succession to add the yum repository.

# yum install -y gcc-c++ make

# curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash –

  1. Install NodeJS and NPM

Run the following command to do install nodejs. This command will install node.js along with npm and other dependent packages.

# yum install nodejs

  1. Verify versions

Having installed packages, you need to check their version.

For checking node.js version

# node -v

For checking npm version

# npm -v

Here you have successfully installed NodeJS and NPM.

Ref: https://www.e2enetworks.com/help/knowledge-base/how-to-install-node-js-and-npm-on-centos/

Install MongoDB.

  1. Add the MongoDB Repository

We will use vi editor here which comes preinstalled.

# vi /etc/yum.repos.d/mongldb.repo

Option A : If you are running a 64 bit system, add the following information to the file you’ve created using above command.

Use i to insert into terminal.

[mongodb]

name=MongoDB Repository

baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/

gpgcheck=0

enabled=1

Then exits and save the file with command :wq

Option B : If you are running a 32 bit system, add the following information to the file you’ve created using above command.

Use i to insert into terminal.

[mongodb]

name=MongoDB Repository

baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686/

gpgcheck=0

enabled=1

Then exits and save the file with command :wq

  1. Install MongoDB

Now simply run this command.

# yum install mongo-10gen mongo-10gen-server

When prompted is this ok [y/N]:, simply type y and hit enter.

It will install MongoDB completely.

  1. Start MongoDB Service

# service mongod start

Here service will start and you can check by running this command.

# service mongod status

Here you have successfully installed MongoDB.

Ref: https://www.liquidweb.com/kb/how-to-install-mongodb-on-centos-6/

Now you can simply clone your GitHub repository into your server and test your node application.

To install git run this command.

# yum install git

To run the node server in background even if you close the shell.

You can use pm2 service.

To learn more, visit this link: http://pm2.keymetrics.io/