This article provides a detailed guide on installing the MEAN stack (MongoDB, Express.js, Angular, and Node.js) on Ubuntu. Follow these step-by-step instructions to set up your development environment, allowing you to build robust web applications using this powerful technology stack.
8 min
Edited:06-10-2024
The MEAN stack is a powerful combination of technologies that allows developers to build dynamic web applications using JavaScript. This guide will walk you through the installation process of each component of the MEAN stack on Ubuntu.
You can update your package list with the following command:
1. sudo apt update
Node.js is a JavaScript runtime that allows you to run JavaScript on the server side. npm (Node Package Manager) comes with Node.js and is used to install JavaScript libraries.
Install Node.js by running:
1. sudo apt install nodejs
Install npm:
1. sudo apt install npm
Install MongoDB
MongoDB is a NoSQL database that stores data in a flexible, JSON-like format.
1. wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
1. echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu focal/multiverse amd64 Packages" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
1. sudo apt update
2. sudo apt install -y mongodb-org
3. sudo systemctl start mongod
4. sudo systemctl enable mongod
Verify MongoDB is running:
1. sudo systemctl status mongod
You can check the full guide on MongoDB installation here:
The Angular CLI is a command-line interface for creating and managing Angular applications.
1. sudo npm install -g @angular/cli
Verify the installation:
1. ng version
Express.js is a web application framework for Node.js that simplifies the process of building web applications and APIs.
Create a directory for your new MEAN application:
1. mkdir my-mean-app
2. cd my-mean-app
Initialize a new Node.js application:
1. npm init -y
Install Express.js:
1. npm install express
Create a simple Express server:
1. const express = require('express');
2. const app = express();
3. const PORT = process.env.PORT || 3000;
4.
5. app.get('/', (req, res) => {
6. res.send('Hello World!');
7. });
8.
9. app.listen(PORT, () => {
10. console.log(`Server is running on http://localhost:${PORT}`);
11. });
Start your Express server:
1. node server.js
Open your browser and navigate to http://localhost:3000 to see the message "Hello World!"
Generate a new Angular application:
1. ng new frontend --routing --style=scss
Navigate into your Angular app directory:
1. cd frontend
Start the Angular development server:
1. ng serve
Open your browser and go to http://localhost:4200 to see your new Angular application.
You have successfully installed the MEAN stack on Ubuntu and created a simple application with Express and Angular. This setup allows you to build full-stack JavaScript applications efficiently. You can now start developing your web applications using the MEAN stack and take advantage of the power of JavaScript on both the front end and back end.
14-10-2024
This article offers a detailed guide on installing and configuring IPTables on an Ubuntu VPS. IPTables is a powerful firewall tool that helps secure your server by controlling inbound and outbound traffic. Learn how to set up rules for traffic filtering, configure basic security policies, and apply custom rules to protect your VPS.
IPtables
security
12 min
This article offers a comprehensive guide on installing and configuring ModSecurity, a powerful web application firewall (WAF), on an Ubuntu VPS. Learn how to secure your server by filtering and monitoring HTTP requests, set up ModSecurity with Nginx or Apache, and apply rules to protect against common web attacks.
Modsecurity
security
10 min
14-10-2024
This article provides a comprehensive guide on installing and configuring PHP-FPM (FastCGI Process Manager) on an Ubuntu VPS. Learn how to optimize PHP performance for your web applications by configuring PHP-FPM with Nginx or Apache, managing pools, and fine-tuning settings for efficient processing of PHP scripts.
PHP-FPM
speed
optimise
12 min