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
sudoprivileges are required to install system packages and manage services. -
Network: The server must have outbound internet access to download packages from
deb.nodesource.comandnpmregistries. -
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
5432is 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
postgresqlpackage (typically/var/lib/postgresqland/etc/postgresql). -
Angular CLI and Express Generator are installed globally, making them available system-wide.
-
The
pgmodule 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:
-
Update the package cache and install prerequisites (
curl,gnupg,software-properties-common). -
Install Node.js version 22.x using the NodeSource setup script.
-
Install PostgreSQL and ensure the service is running and enabled.
-
Install Angular CLI globally.
-
Install Express Generator globally.
-
Install the
pgpackage.
For Debian Systems:
-
Update the package cache and install prerequisites (
curl,gnupg,software-properties-common). -
Install Node.js version 18.x using the NodeSource setup script.
-
Install PostgreSQL and ensure the service is running and enabled.
-
Install Angular CLI globally.
-
Install Express Generator globally.
-
Install the
pgpackage.
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
pgpackage 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:
-
Stop the service:
-
Restart the service:
-
Enable on boot:
Updating Node.js Packages: To update the global Node.js packages, the following commands are used:
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.