How to Install NodeBB Forum on Debian 9

NodeBB is a Node.js based forum software built for the modern web. It's built on either a MongoDB or Redis database. It utilizes web sockets for instant interactions and real-time notifications. NodeBB has many modern features out of the box such as social network integration and streaming discussions. Additional functionality is enabled through the use of third-party plugins. NodeBB is an open source project which can be found on Github. In this guide, we will guide you step-by-step through the NodeBBB installation process on the Debian 9 operating system using Nginx as the reverse proxy, MongoDB as the database, and and Let's Encrypt for HTTPS.


NodeBB requires the following software to be installed:

  • Node.js version 6 or greater
  • MongoDB version 2.6 or greater or Redis version 2.8.9 or greater
  • Nginx version 1.3.13 or greater
  • Git

NOTE: Installing NodeBB's dependencies may require more than 512 megabytes of system memory. It is recommended to enable a swap partition to compensate if your Linux system has insufficient memory.


  • A running Debian 9 system with at least 1GB of RAM.
  • Domain name with A/AAAA records set up.
  • A non-root user with sudo privileges.

Initial steps

Check your Debian version:

lsb_release -ds

Set up the timezone:

sudo dpkg-reconfigure tzdata

Update your operating system packages (software). This is an important first step because it ensures you have the latest updates and security fixes for your operating system's default software packages:

sudo apt update && sudo apt upgrade -y

Install some essential packages that are necessary for basic administration of the Debian operating system:

sudo apt install -y curl wget vim git unzip sudo socat bash-completion apt-transport-https

Step 1: Install Node.js and npm

NodeBB is built on Node.js. We are going to install the recommended version for NodeBB which is version 8 at the time of this writing. On Linux, you have a few Node.js installation options: Linux Binaries (x86/x64), Source Code or via Package Managers. We will use the Package Management option which makes installing and updating Node.js a breeze.

Download and install the latest Long-Term Support (LTS) release of Node.js from the NodeSource repo:

curl -sL | sudo -E bash -
sudo apt install -y nodejs

To compile and install native add-ons from npm you may also need to install build tools:

sudo apt install -y build-essential

NOTE: npm is distributed with Node.js - which means that when you download Node.js, you automatically get npm installed on your system.

Check the Node.js and npm versions:

node -v && npm -v
# v10.15.1
# 6.4.1

Npm is a separate project from Node.js and tends to update more frequently. As a result, even if you’ve just downloaded Node.js (and therefore npm), you’ll probably need to update your npm. Luckily, npm knows how to update itself! To update your npm, type this into your terminal:

sudo npm install -g npm@latest

This command will update npm to the latest stable version.

Re-check npm version with:

npm -v
# 6.7.0

And it should return the latest version numbers.

Step 2: Install and configure MongoDB

NodeBB needs a database to store its data, and it supports MongoDB and Redis. In this tutorial, we chose MongoDB as the data store engine. So, in the next few steps, we will download and install MongoDB database from the official MongoDB rpm repository:

To install the stable version of MongoDB package from the official MongoDB repository, issue the following command:

sudo apt-key adv --keyserver hkp:// --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
echo "deb stretch/mongodb-org/4.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
sudo apt update
sudo apt install -y mongodb-org

Check the MongoDB version:

mongo --version | head -n 1 && mongod --version | head -n 1

Start and enable (set it to start on rebootMongoDB service:

sudo systemctl start mongod.service
sudo systemctl enable mongod.service

Check the MongoDB Database Server status by running:

sudo systemctl status mongod.service
# active (running)

Next, create a MongoDB database and user for NodeBB.

Connect to MongoDB server first.


Switch to the built-in admin database.

> use admin

Create an administrative user.

> db.createUser( { user: "admin", pwd: "<Enter a secure password>", roles: [ { role: "readWriteAnyDatabase", db: "admin" }, { role: "userAdminAnyDatabase", db: "admin" } ] } )

NOTE: Replace the placeholder <Enter a secure password> with your own selected password.

Add a new database called nodebb.

> use nodebb

The database will be created and context switched to nodebb. Next, create the nodebb user with the appropriate privileges.

> db.createUser( { user: "nodebb", pwd: "<Enter a secure password>", roles: [ { role: "readWrite", db: "nodebb" }, { role: "clusterMonitor", db: "admin" } ] } )

NOTE: Again, replace the placeholder <Enter a secure password> with your own selected password.

Exit the Mongo shell.

> quit()

Restart MongoDB and verify that the administrative user created earlier can connect.

sudo systemctl restart mongodb.service
mongo -u admin -p your_password --authenticationDatabase=admin

If all went well, your MongoDB should be installed and prepared for NodeBB. In the next step, we will deal with web server installation and configuration.

Step 3 - Install client and obtain Lets Encrypt certificate

This step is optional. Securing your NodeBB Forum with HTTPS is not necessary, but it is a good practice to secure your site traffic. In order to obtain TLS certificate from Let's Encrypt we will use client. is a pure Unix shell software for obtaining TLS certificates from Let's Encrypt with zero dependencies. 

Download and install

sudo su - root
git clone
./ --install --accountemail [email protected]
source ~/.bashrc
cd ~

Check version: --version
# v2.8.0

Obtain RSA and ECC/ECDSA certificates for your domain/hostname:

# RSA 2048 --issue --standalone -d --keylength 2048
# ECDSA --issue --standalone -d --keylength ec-256

If you want fake certificates for testing you can add --staging flag to the above commands.

After running the above commands, your certificates and keys will be in:

  • For RSA: /home/username/ directory.
  • For ECC/ECDSA: /home/username/example.com_ecc directory.

To list your issued certs you can run: --list

Create a directory to store your certs. We will use /etc/letsencrypt directory.

mkdir -p /etc/letsecnrypt/
sudo mkdir -p /etc/letsencrypt/example.com_ecc

Install/copy certificates to /etc/letsencrypt directory.

# RSA --install-cert -d --cert-file /etc/letsencrypt/ --key-file /etc/letsencrypt/ --fullchain-file /etc/letsencrypt/ --reloadcmd "sudo systemctl reload nginx.service"
# ECC/ECDSA --install-cert -d --ecc --cert-file /etc/letsencrypt/example.com_ecc/cert.pem --key-file /etc/letsencrypt/example.com_ecc/private.key --fullchain-file /etc/letsencrypt/example.com_ecc/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"

All the certificates will be automatically renewed every 60 days.

After obtaining certs exit from root user and return back to normal sudo user:


Step 4: Install and configure Nginx

NodeBB can work fine with many web servers. In this tutorial, we selected Nginx.

Install Nginx package, by issue the following command:

sudo apt install -y nginx

After the installation, you can verify the Nginx version by running:

nginx -v

Start and enable (set it to start on reboot) Nginx service:

sudo systemctl start nginx.service
sudo systemctl enable nginx.service

Check the Nginx web server status by running:

sudo systemctl status nginx.service
# active (running)

NodeBB by default runs on port 4567. To avoid typing, we will configure Nginx as a reverse proxy for the NodeBB application. Every request on port 80 or 443 (if SSL is used) will be forwarded to port 4567.

Run sudo vim /etc/nginx/conf.d/nodebb.conf and configure Nginx as an HTTPS reverse proxy.

server {
listen [::]:443 ssl http2;
listen 443 ssl http2;
listen [::]:80;
listen 80;


client_max_body_size 50M;

ssl_certificate /etc/letsencrypt/;
ssl_certificate_key /etc/letsencrypt/;
ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com_ecc/private.key;

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
# Socket.IO Support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";


Check the Nginx configuration:

sudo nginx -t

Finally, for changes to take effect, we need to reload Nginx:

sudo systemctl reload nginx.service

Step 5: Install and setup NodeBB

Create a document root directory where NodeBB should reside in:

sudo mkdir -p /var/www/nodebb

Navigate to the document root directory:

cd /var/www/nodebb

Change ownership of the /var/www/nodebb directory to your_user.

sudo chown -R [your_user]:[your_user] /var/www/nodebb

NOTE: Replace your_user in the above command with your non-root user that you should have created as a prerequisite for this tutorial.

Clone the latest NodeBB repository into document root folder:

git clone -b v1.11.x .

Initiate the setup script by running the app with the setup flag. Answer each of the questions:

./nodebb setup

After NodeBB setup is completed, run ./nodebb start to manually start your NodeBB server:

./nodebb start

After running this command, you should be able to access your brand new forum in your web browser:

NodeBB in Browser

Step 6: Run NodeBB as a System Service

When started via ./nodebb start, NodeBB will not automatically start up again when the system reboots. To avoid that, we will need to setup NodeBB as a system service.

If running, stop NodeBB:

./nodebb stop

Create a new nodebb user:

sudo useradd nodebb

Change the ownership of the /var/www/nodebb directory to nodebb user:

sudo chown -R nodebb:nodebb /var/www/nodebb

Create a nodebb.service systemd unit config file. This unit file will handle the startup of NodeBB daemon. Run sudo vim /etc/systemd/system/nodebb.service and add the below content:

After=system.slice mongod.service



ExecStart=/usr/bin/env node loader.js


NOTE: Set username and directory paths according to your chosen names.

Enable nodebb.service on reboot and immediately start nodebb.service:

sudo systemctl enable nodebb.service
sudo systemctl start nodebb.service

Check the nodebb.service status:

sudo systemctl status nodebb.service
sudo systemctl is-enabled nodebb.service

Congratulations! You have successfully installed and deployed NodeBB discussion platform on the Debian 9 system. You should be able to access your forum on your domain and interact with your forum.


Share this page:

1 Comment(s)