DEV Community

Cover image for Deploy A Web Book Register Application With AWS And MEAN stack
Abisola Adesegun
Abisola Adesegun

Posted on

Deploy A Web Book Register Application With AWS And MEAN stack

Table of Contents
Step 1: Provision an AWS Instance
Step 2: Install Node.js
Step 3: Install MongoDB
Step 4: Install Express and Set Up Routes
Step 5: Access the Routes with AngularJS
Step 6: Run the App

Deploying a Web Book Register Application on an Ubuntu AWS EC2 instance using the MEAN stack (MongoDB, Express, Angular, Node.js) involves several steps. Here’s a step-by-step guide:

Step 1: Provision an AWS Instance
Launch an EC2 Instance:

  • Use the AWS Console to launch an Ubuntu Server (e.g., 22.04 LTS).

Image description

Image description

  • Choose an instance type (e.g., t2.micro for free tier).

Image description

  • Configure security groups to allow:

SSH (port 22) for server access.
HTTP (port 80) and HTTPS (port 443) for web traffic.

Image description

Image description

  • Connect to the Instance:

Image description

Image description

Step 2: Install Node.js
Node.js is a free, open-source, cross-platform JavaScript runtime environment that lets developers create servers, web apps, command line tools and scripts.

  • Update System Packages:

Image description

Image description

Image description

  • Add certificates:

Image description

Image description

  • Install Node.js:

Image description

Image description

Step 3: Install MongoDB
Follow these steps to install MongoDB Community Edition using the apt package manager.

  • Install gnupg and curl if they are not already available:

Image description

Image description

Image description

  • Create the List File Create the list file for Ubuntu 24.04 (Noble):

Image description

Image description

  • Reload the Package Database Issue the following command to reload the local package database:

Image description

Image description

  • Install MongoDB Community Server You can install either the latest stable version of MongoDB or a specific version of MongoDB.

Image description

Image description

  • Init System

To run and manage your mongod process, you will be using your operating system's built-in init system.
If you are unsure which init system your platform uses, run the following command:

Image description

  • Start and verify MongoDB. You can start the mongod process and Verify that MongoDB has started successfully by issuing the following commands:

Image description

Image description

  • Install npm (Node Package Manager):

Image description

Image description

Note: I faced issues with installing the npm, so I used aptitude to Resolve Dependencies. If you face issues, you can try using aptitude (an alternative package manager) to handle the dependency resolution:
aptitude:

  • Install aptitude:

Image description

Then, try installing npm using:

Image description

Image description

  • Install the body-parser package:

Image description

Image description

  • Create a folder for the project:

Image description

  • Initialize the npm project:

Image description

Image description

  • Create a file named server.js and add the following code:

Image description

Image description

Step 4: Install Express and Set Up Routes

  • Install Express and Mongoose:

Image description

  • Create a folder named apps:

Image description

  • Create a file named routes.js and add the following code:

Image description

Image description

Image description

  • Create a folder named models:

Image description

  • Create a file named book.js and add the following code:

Image description

Image description

Step 5: Access the Routes with AngularJS

  • Change the directory back to Books:

Image description

  • Create a folder named public

Image description

Image description

  • Create a file named script.js and add the following code:

Image description

Image description

  • In the public folder, create a file named index.html and add the following code:

Image description

Image description

Image description

Step 6: Run the App

  • Go back to the project root directory and run the following command:

Image description

Image description

  • Opening TCP port 3300 on AWS Web Console for your EC2 Instance to access it from the Internet.

Image description

  • Accessing the Book Register Application by opening a browser and going to http://:3300

Image description

  • Testing the Book Management Application:

Image description

Top comments (0)