How to Install the MEAN Stack on Your Ubuntu 17.10 Server

How to Install the MEAN Stack on Your Ubuntu 17.10 Server

Installing MEAN stack on your Linux virtual server (Ubuntu 17.10) has never been this easy. The following guided steps will take you through the installation as you prepare to launch your first MEAN stack application.

Introduction to MEAN Stack

Mean, a web stack, that incorporates Node.JS, MongoDB, Angular.JS, and Express.JS. Use “sudo” to run commands with root privileges.

Getting Started

Your machine has to be set up in readiness for the installation. The first step is to update your Ubuntu repository. Open the terminal and type the following commands;

$ sudo apt-get update

The next step is to ensure that git is installed. To install git type the following command.

$ sudo apt install git

Now we have the prerequisite requirements.

Installing MongoDB

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

MongoDB is a server-side database that supports JavaScript execution by saving data in JSON format, for it does not support SQL.

  1. Import Package Installation Public Key
    The first step is importing the public key for the package. In order to ensure consistency and maintain authenticity, the Ubuntu package management tools (apt) requires GPG keys to be provided by the distributors. To import MongoDB keys, run the following commands.
    $ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5

    If you have logged in as the root user, it will not prompt for a password, however, if the password is requested, add the root user password.

  2. Create MongoDB source list file
    The next step is creating the file list based on Ubuntu 17.10. If you have a different Ubuntu version, use this link to find the appropriate distribution. A MongoDB list will be created in /etc/apt/sources.list.d/ using this command;
    $ echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
  3. Update Repo
    The next step is updating the repository. Run the following command
    $ sudo apt-get update
  4. Installing Mongo DB
    We now install MongoDB files using this line of command
    $ sudo apt-get install -y mongodb-org
  5. Starting MongoDB
    With the mongod.service created automatically, we will now start MongoDB by running these commands:
    $ sudo systemctl start mongod

    To ensure the service is started anytime you boot your machine, run this command:

    $ sudo systemctl enable mongod
  6. Verification of the Installation
    To verify the installation was successful, run the following commands
    sudo lsof - iTCP -sTCP:LISTEN | grep mongo

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 running the following commands:

$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
$ sudo apt-get install -y nodejs

In order to avoid errors from npm packages while compiling run the following commands

$ sudo apt-get install build-essential

Installing Dependencies

To install all the dependencies run the following commands

$ npm install

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. We will use global installation standards (-g).

Run the following command to install bower and gulp respectively.

$ npm install -g bower
$ npm install -g gulp

Installing Mean -cli

Mean.io framework will be used for creation of apps. It will use Mean-cli as the core package. In order to install Mean-cli, run the following commands:

$ npm install -g mean-cli

to check whether the installation was successful run the following command

$ npm list -g --depth=0 | grep mean

Running the First App

To create the first project on Mean.io run the following command:

$ mean init myapp

where ‘myapp’ is the name of your application.

You now need to access the directory with app by running the following:

$ cd myapp

You now need to install the server and client-side dependencies by running the following commands

$ sudo npm install
$ bower install

To initiate the new project run the following

$ gulp

This should give you something like this on your browser on  http://localhost:3000

 

Check out the top 3 Linux hosting services

Webdock
$1.05 /mo
Starting price
Visit Webdock
Rating based on expert review
  • User Friendly
    3.8
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.3
  • Pricing
    4.3
Kamatera
$4.00 /mo
Starting price
Visit Kamatera
Rating based on expert review
  • User Friendly
    3.5
  • Support
    3.0
  • Features
    3.9
  • Reliability
    4.0
  • Pricing
    4.3
Ultahost
$2.50 /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 Configure Nginx and Apache on the same Ubuntu VPS or Dedicated Server

Nginx and Apache are great and powerful web servers. However, they both have dra
less than a minute
Idan Cohen
Idan Cohen
Marketing Expert

Use Python to Automate Routine Tasks on Your VPS or Dedicated Server

Here we'll use basic knowledge of Python to teach you how to leverage the extrao
less than a minute
Md. Ehsanul Haque Kanan
Md. Ehsanul Haque Kanan
Hosting Expert

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
less than a minute
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to Connect to a Server by Using SSH on Linux and Mac

Most servers in the world are run on Linux servers. They’re dependable, afford
less than a minute
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert
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