In this guide you’ll learn to install NodeBB on Ubuntu 18.04/16.04. NodeBB is free and open source forum software written in Node.js and utilizes web sockets for instant interactions and real-time notifications. NodeBB can be integrated into your website or social media sites to keep your customers updated and engaged. When setting up NodeBB, you can choose from either Redis or MongoDB database.

Some good features of NodeBB are:

  • Social network integration and streaming discussions
  • Compatible with most browsers including old ones.
  • Has Built-in localization with support for over 50 languages
  • Has Analytics dashboard with real-time data of content views

Our NodeBB installation will have the following requirements:

  1. Node.js
  2. Database – MongoDB

Step 1: Installing Node.js

Node.js is a rapidly evolving platform and it drives NodeBB. On Ubuntu and Debian systems, you can install Node.js  from the NodeSource repository:

sudo apt update
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get -y install gcc g++ make nodejs

You should have version 8 of Node.js  installed alongside npm. Verify versions using:

$ node -v
v10.17.0
$ npm -v
6.11.3

Step 2: Install MongoDB Database on Ubuntu 18.04

MongoDB is the default database for NodeBB. Use the guide below to install MongoDB

Install MongoDB on Ubuntu

Verify installation of MongoDB. You should have version 3.6:

$ mongod --version
db version v4.2.1
git version: edf6d45851c0b9ee15548f0f847df141764a317e
OpenSSL version: OpenSSL 1.1.1  11 Sep 2018
allocator: tcmalloc
modules: none
build environment:
  distmod: ubuntu1804
  distarch: x86_64
  target_arch: x86_64

Step 3: Configure MongoDB

MongoDB comes with a Shell mongo used for general administration. A default installation of MongoDB listens on port 27017 and is accessible locally. Access the shell using:

$ mongo

Escalate to admin built-in database:

> use admin
switched to db admin

Create an administrative user:

> db.createUser( { user: "admin", pwd: "adminpassword", roles: [ { role: "readWriteAnyDatabase", db: "admin" }, { role: "userAdminAnyDatabase", db: "admin" } ] } )

This user is scoped to the databaseadmin to manage MongoDB once authorization has been enabled. Replace adminpassword with your desired admin password.

Add a new database called nodebb:

> use nodebb
switched to db nodebb

Next, create the nodebb user with the appropriate privileges:

> db.createUser( { user: "nodebb", pwd: "password", roles: [ { role: "readWrite", db: "nodebb" }, { role: "clusterMonitor", db: "admin" } ] } )
  • The permissionreadWrite allows NodeBB to store and retrieve data from the databasenodebb.
  • The permissionclusterMonitor provides NodeBB read-only access to query database server statistics which are then exposed in the NodeBB Administrative Control Panel (ACP).

Lastly, exit the Mongo Shell:

> quit()

Enable database authorization in the MongoDB configuration file /etc/mongod.conf by appending the following lines:

security:
authorization: enabled

Restart MongoDB and verify the administrative user created earlier can connect:

$ sudo systemctl restart mongod
$ mongo -u admin -p adminpassword --authenticationDatabase=admin
MongoDB shell version v3.6.5
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.5
>

Step 4: Install NodeBB on Ubuntu 18.04

Make sure git is installed:

$ sudo -y apt-get install git

Clone stable branch of NodeBB:

$ git clone  https://github.com/NodeBB/NodeBB.git nodebb
Cloning into 'nodebb'...
remote: Counting objects: 151894, done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 151894 (delta 10), reused 16 (delta 8), pack-reused 151867
Receiving objects: 100% (151894/151894), 45.92 MiB | 15.51 MiB/s, done.
Resolving deltas: 100% (115325/115325), done.
$ cd nodebb

A list of alternative branches are available in the NodeBB Branches GitHub page, but only the versioned branches are stable.

NodeBB has a command line utility used to setup NodeBB.We will use it to setup NodeBB, this will install modules from npm and then enter the setup utility.

$ ./nodebb setup
2018-06-21T21:03:34.559Z [3956] - info: NodeBB Setup Triggered via Command Line

Welcome to NodeBB v1.9.3!

This looks like a new installation, so you'll have to answer a few questions about your environment before we can proceed.
Press enter to accept the default setting (shown in brackets).
URL used to access this NodeBB (http://localhost:4567) <Enter>
Please enter a NodeBB secret (48e1fe7e-a54a-4329-a4d1-448970f4e530) <Enter>
Which database to use (mongo) <Enter>
2018-06-21T21:03:38.835Z [3956] - info: 
Now configuring mongo database:
MongoDB connection URI: (leave blank if you wish to specify host, port, username/password and database individually)
Format: mongodb://[username:[email protected]]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]<Enter>
Host IP or address of your MongoDB instance (127.0.0.1) <Enter>
Host port of your MongoDB instance (27017) <Enter>
MongoDB username nodebb
Password of your MongoDB database 
MongoDB database name (nodebb) 
2018-06-21T21:04:05.019Z [3956] - info: [database] Checking database indices.
2018-06-21T21:04:05.063Z [3956] - info: [database] Checking database indices done!
Configuration Saved OK
Populating database with default configs, if not already set...
2018-06-21T21:04:06.670Z [3956] - warn: [cache-buster] could not read cache buster message=ENOENT: no such file or directory, open '/home/jmutai/nodebb/build/cache-buster', stack=Error: ENOENT: no such file or directory, open '/home/jmutai/nodebb/build/cache-buster', errno=-2, code=ENOENT, syscall=open, path=/home/jmutai/nodebb/build/cache-buster
Enabling default theme: nodebb-theme-persona
No categories found, populating instance with default categories
2018-06-21T21:04:08.001Z [3956] - warn: No administrators have been detected, running initial user setup
Administrator username admin
Administrator email address [email protected]
Password 
Confirm Password 
......
NodeBB Setup Completed. Run "./nodebb start" to manually start your NodeBB server.

To start nodebb, run:

$ ./nodebb start

Starting NodeBB
"./nodebb stop" to stop the NodeBB server
"./nodebb log" to view server output
"./nodebb help" for more commands

Step 5: Install and Configure Nginx

NodeBB by default runs on port 4567. We will configure Nginx to proxy requests to it.

Install nginx:

sudo apt -y install nginx

Configuring nginx

Create nginx configuration file:

$ sudo vim /etc/nginx/conf.d/nodebb.conf

Then add content:

server {
    listen 80;

    server_name forum.computingforgeeks.com;

    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_pass http://127.0.0.1:4567;
        proxy_redirect off;

        # Socket.IO Support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Check if service running:

$ ss -tunelp | grep 4567
tcp LISTEN 0 128 0.0.0.0:4567 0.0.0.0:* users:(("node",pid=4068,fd=13)) uid:1000 ino:506425 sk:6 <->

Restart nginx:

sudo systemctl restart nginx

Step 5: Access NodeBB Web interface

To this point, you should have successfully install NodeBB on Ubuntu 18.04/16.04 server. You should be able to access http://forum.example.com and interact with your forum.

To access admin dashboard, use http://forum.example.com/admin instead.

Thanks for using our guide is a reference while installing NodeBB on Ubuntu 18.04 Linux system.

Similar:

Install discourse on Ubuntu 18.04