Skip to content

Deployment Overview of MEAN on Server

Prerequisites and Basic Requirements

The MEAN stack deployment requires a Linux server running either Ubuntu or Debian. The installation process assumes the following system conditions:

  • Operating System: Ubuntu or Debian (specific versions not restricted in the provided configuration, but Node.js versions differ by OS).

  • Privileges: Root access or sudo privileges are required to install system packages and manage services.

  • Network: The server must have outbound internet access to download packages from deb.nodesource.com and npm registries.

  • Ports: The application utilizes standard ports for Node.js services and PostgreSQL. Specific port numbers are defined in the application configuration, which is not explicitly detailed in the source files, but standard PostgreSQL port 5432 is used.

File and Directory Structure

The deployment installs global Node.js packages and system-level components. The resulting structure includes:

  • Node.js binaries and modules are installed globally via npm.

  • PostgreSQL data and configuration files are stored in the default locations managed by the postgresql package (typically /var/lib/postgresql and /etc/postgresql).

  • Angular CLI and Express Generator are installed globally, making them available system-wide.

  • The pg module is installed locally within the application context or globally depending on the execution environment, serving as the PostgreSQL client for Node.js.

Application Installation Process

The installation is performed by executing a sequence of package installations and service configurations. The process differs slightly between Ubuntu and Debian regarding the Node.js version.

For Ubuntu Systems:

  1. Update the package cache and install prerequisites (curl, gnupg, software-properties-common).

  2. Install Node.js version 22.x using the NodeSource setup script.

  3. Install PostgreSQL and ensure the service is running and enabled.

  4. Install Angular CLI globally.

  5. Install Express Generator globally.

  6. Install the pg package.

For Debian Systems:

  1. Update the package cache and install prerequisites (curl, gnupg, software-properties-common).

  2. Install Node.js version 18.x using the NodeSource setup script.

  3. Install PostgreSQL and ensure the service is running and enabled.

  4. Install Angular CLI globally.

  5. Install Express Generator globally.

  6. Install the pg package.

The specific commands executed during the installation are:

# Prerequisites
apt-get update
apt-get install -y curl gnupg software-properties-common

# Node.js (Ubuntu - Version 22.x)
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo bash -
sudo apt-get install -y nodejs

# Node.js (Debian - Version 18.x)
curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
apt-get install -y nodejs

# PostgreSQL
apt-get install -y postgresql
systemctl start postgresql
systemctl enable postgresql

# Global NPM Packages
npm install -g @angular/cli
npm install -g express-generator
npm install pg

Databases

The deployment includes the PostgreSQL database server.

  • Database Engine: PostgreSQL

  • Service Name: postgresql

  • Status: The service is configured to start automatically on boot (enabled: yes) and is started immediately after installation.

  • Client Library: The pg package is installed to allow Node.js applications to connect to the PostgreSQL database.

  • Storage: Data is stored in the default PostgreSQL data directory managed by the operating system package.

Starting, Stopping, and Updating

The PostgreSQL database service is managed using standard system service commands. The Node.js components (Angular CLI, Express) are command-line tools and do not run as background services by default; they are invoked directly when building or running applications.

PostgreSQL Service Management:

  • Start the service:

    systemctl start postgresql
    

  • Stop the service:

    systemctl stop postgresql
    

  • Restart the service:

    systemctl restart postgresql
    

  • Enable on boot:

    systemctl enable postgresql
    

Updating Node.js Packages: To update the global Node.js packages, the following commands are used:

npm update -g @angular/cli
npm update -g express-generator
npm update pg

To update the Node.js runtime itself, the respective NodeSource setup script for the OS version must be re-executed followed by an apt-get upgrade for the nodejs package.

question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×