In the previous blog MEAN Stack: Introduction – Part 1, I have given a brief introduction of MEAN Stack and all the technologies used in it. In this blog, I’ll be discussing the installation of all the technologies one by one for Ubuntu.
MongoDB: MongoDB is an open-source document database that provides high performance, high availability, and automatic scaling. The installation of MongoDB Community Edition on ubuntu using .deb packages:
- Import the public key used by the package management system using the command:
sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv 9DA31620334BD75D9DCB49F368818C72E52529D4
- Create a list file for Mongo DB using the command:
- For Ubuntu 14.04 (Trusty):
echo “deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/4.0 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
- For Ubuntu 16.04 (Xenial):
echo “deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
- For Ubuntu 18.04 (Bionic):
echo “deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
- For Ubuntu 14.04 (Trusty):
- Reload local package database:
sudo apt-get update
- For the latest version:
sudo apt-get install -y mongodb-org
For the specific version:
sudo apt-get install -y mongodb-org=4.0.4 mongodb-org-server=4.0.4 mongodb-org-shell=4.0.4 mongodb-org-mongos=4.0.4 mongodb-org-tools=4.0.4
Optional:
Although you can specify any available version of MongoDB, apt-get will upgrade the packages when a newer version becomes available. To prevent unintended upgrades, you can pin the package at the currently installed version by following commands:
-
-
echo "mongodb-org hold" | sudo dpkg –set-selections
-
echo "mongodb-org-server hold" | sudo dpkg –set-selections
-
echo "mongodb-org-shell hold" | sudo dpkg –set-selections
-
echo "mongodb-org-mongos hold" | sudo dpkg –set-selections
-
echo "mongodb-org-tools hold" | sudo dpkg –set-selections
-
After installation, the commands to run the MongoDB are:
-
Start MongoDB
sudo service mongod start
- Verify that the MongoDB process has started successfully by checking the contents of the log file at /var/log/mongodb/mongod.log for a line reading:
[initandlisten] waiting for connections on port 27017
-
Stop MongoDB
sudo service mongod stop
-
Restart MongoDB
sudo service mongod restart
-
Open Mongo shell
mongo
For any other query regarding installation, visit MongoDB Documentation
Node: Node.js is an open source cross-platform JavaScript run-time environment that allows server-side execution of JavaScript code which simply means that you can run JavaScript code on your machine as a standalone application, free of any web browser. Installation of the node on Ubuntu from Ubuntu repository:
-
Reload local package database:
sudo apt-get update
-
Install nodejs and npm using the apt package manager:
sudo apt install nodejs npm
Verify the installation by executing the following commands:
-
For nodejs :
nodejs –version
Output: v8.10.0 - For npm:
npm –version
Output: 3.5.2
NPM (Node Package Manager) gives you the ability to download Node modules or packages to extend the functionality of your application.
For any other query regarding installation, visit Node JS Documentation.
Express: Expres is a web application framework for Node. In basic terms, an Express application is simply a Node application that happens to use Express as the framework. Express can be added in our project by using NPM (Node Package Manager):
npm install –save express
Angular: Angular is a platform that makes it easy to build applications with the web. Angular combines declarative templates, dependency injection, an end to end tooling, and integrated best practices to solve development challenges. Angular empowers developers to build applications that live on the web, mobile, or the desktop.
The setup of Angular is done by using Angular CLI (Command Line Interface). Angular CLI can be installed by using NPM (Node Package Manager):
sudo npm install -g @angular/cli
The angular project can be set up by using the following commands:
- Create a new Angular project using
ng new <project_name>
- Now change the directory to project folder
cd <project_name>
- Now start the development server using
ng serve –open
Now, check in the browser that your application started running at default URL:
You can also add angular material for better UI experience. To install angular material in your application use command:
npm install –save @angular/material
For any other query regarding installation, visit Angular Documentation.
Few Important Points
-
For better UI of Mongo DB download Studio 3T, a professional MongoDB GUI. It Queries faster with the most powerful MongoDB GUI and IDE. It is available for all Windows, macOS, and Linux. Download
-
Use Virtual Studio for development because that simply makes breaking with our code much easier. It is free, open source and available for all platforms. Download
sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
This is the right one not yours!
Yes this one is the right key not mine