PM2 is a process manager for Node.JS applications with a built-in load balancer. NGINX is popular web server and reverse proxy software. This tutorial will guide you on how to deploy MERNMail application with PM2 and NGINX on GNU/Linux systems.
## 2. Install Dependencies and Build the Application
Navigate to the project directory, install the necessary dependencies, and build the MERNMail application:
```bash
npm install
npm run build
```
## 3. Configuration
Copy the `.env.example` file to a `.env` file in the root directory of the project. The configuration options can be found in the [Configuration](/docs/configuration) page.
Install NGINX using `sudo apt install nginx` on Debian-based systems, `sudo pacman -S nginx` on Arch-based systems, or `sudo dnf install nginx` on Red Hat-based systems.
After installing NGINX, open your preferred text editor, and save these contents to the `/etc/nginx/sites-available/mernmail` file (replace `/home/user` with path to your home directory; also check the port the MERNMail application listens to; this configuration causes NGINX to only listen to port 80):