How to Install the MEAN Stack on Your CentOS 7 VPS or Dedicated Server

How to Install the MEAN Stack on Your CentOS 7 VPS or Dedicated Server

Introduction to MEAN Stack

This article will take you through the installation of MEAN stack on your Linux virtual server based on CentOS 7.

MEAN is a JavaScript software stack that contains Node.JS, Angular.JS, and Express.JS. It uses MongoDB as the default database. In order to install the stack, it is necessary to have root permissions. However, if you do not have the root permissions, ensure that your commands start with “sudo”.

 

Getting Started

The first step is setting up your Machine for the installation. Before any installation begins, ensure that your machine has the following

  • Git. Confirm that you have GIT installed in your system. To confirm the installation run the command # git --version on the terminal.
  • Ensure that dependencies are installed. Run the following commands
    # gem install sass
# yum install gcc-c++ make git fontconfig bzip2 libpng-devel ruby  ruby-devel

Installing MongoDB

Special Note: Consult with Hostadvice’s Best MongoDB hosting page to find the top MongoDB hosting services. .

.MongoDB is a NoSQL database system that saves data in JSON format thereby supporting server-side JavaScript execution. Since it is not listed on the official CentOS repository, we will need to create one to download the latest stable version. Type the following to create a new file with your text editor

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

This will open a new text file.  Paste the following code and save it, then exit the editor.

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

Install MongoDB by running the following command:

# yum install mongodb-org

Once the installation is complete, start and enable the database service with the following commands:

# systemctl start mongod
#systemctl enable mongod

To verify that the service is running, run the following command

# systemctl status mongod

Installing Node JS.

Special Note: Consult with Hostadvice’s Best Node.js hosting page to find the top Node.js hosting services.

 

Node JS is a JavaScript execution environment that acts as a server-side. Installing Node.js is done by adding the repository of a stable branch. This is done by running this command:

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

The next step is installing Node JS and NPM

#  yum install -y nodejs

Check whether the installation was successful by running

# npm version
# node version

Installing Bower and Gulp

These are components of the mean stack. Bower is a package manager for the front-end apps, while gulp automates tasks. The installation of both must be global so that they are available system-wide.

Run the following command to install bower and gulp respectively.

# npm install -g bower
# npm install -g gulp

Verify the installation was successful by running these commands

# npm list -g --depth=0

This should yield the following

/usr/lib
├── bower@1.8.4
├── gulp@4.0.0
└── npm@5.8.0

Installing MEAN

Now that are the prerequisite installations are done, it is time to install Mean boilerplate. This is done by cloning it from github.

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

With the boilerplate on your home directory, you need to install the project references by accessing the directory. Run;

# cd mean

To install mean run:

# npm install

This might take a few minutes but once install front-end resources by typing;

# bower install --allow-root

Running the First Application

To start MEAN stack project, use the commands below:

# npm start

At first you might experience the following error
Error output

[12:56:49] ‘lint’ errored after 702 ms
[12:56:49] Error in plugin ‘run-sequence’
Message:
An error occurred in task ‘sass’

Correct the errors by running these commands:

# rm -rf node_modules
# npm cache clean
# npm install
# npm start

To access the MEAN application, type the link below on your browser:

http://your_server_ip:3000

It should yield a page like the one below.

You can start building and deploying your applications.

 

Check out the top 3 Dedicated server hosting services:

Hostinger
NZ$5.05 /mo
Starting price
Visit Hostinger
Rating based on expert review
  • User Friendly
    4.7
  • Support
    4.7
  • Features
    4.8
  • Reliability
    4.8
  • Pricing
    4.7
IONOS
NZ$1.69 /mo
Starting price
Visit IONOS
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.3
Ultahost
NZ$4.90 /mo
Starting price
Visit Ultahost
Rating based on expert review
  • User Friendly
    4.3
  • Support
    4.8
  • Features
    4.5
  • Reliability
    4.0
  • Pricing
    4.8

How To Set up a VSFTPD Server on a CentOS 7 VPS or Dedicated Server

Brief Description FTP is usually insecure exposing clear-text passwords, userna
2 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert

How to Set Up SSH on a CentOS 7 VPS from a Windows Client

Download puttygen into the Windows machine as shown in figure 1. Then sta
4 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester

How to Install MongoDB on Your CentOS 7 VPS or Dedicated Server

MongoDB is designed for extensive databases and is mainly used for data analytic
2 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to install Django on a CentOS 7 VPS or Dedicated Server

When building a website, similar components are required, and you do not have to
3 min read
Mark Armistead
Mark Armistead
Author
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top