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:
- Node.js
- 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:
$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - $ sudo apt-get install gcc g++ make $ sudo apt-get install -y nodejs
You should have version 8 of Node.js installed alongside npm. Verify versions using:
$ node -v v8.11.3 $ npm -v 5.6.0
Step 2: Install MongoDB Database on Ubuntu 18.04
MongoDB is the default database for NodeBB. Start the installation by importing the public key used by the package management system.
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
Add MongoDB repository
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
Update apt package index and install MongoDB server:
$ sudo apt-get update $ sudo apt-get install -y mongodb-org
Start MongoDB service:
$ systemctl start mongod.service $ systemctl enable mongod.service
Verify installation of MongoDB. You should have version 3.6:
$ mongod --version db version v3.6.5 git version: a20ecd3e3a174162052ff99913bc2ca9a839d618 OpenSSL version: OpenSSL 1.0.2n 7 Dec 2017 allocator: tcmalloc modules: none build environment: distmod: ubuntu1604 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:
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 permission
readWrite
allows NodeBB to store and retrieve data from the databasenodebb
. - The permission
clusterMonitor
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 apt-get install -y git
Clone stable branch of NodeBB:
This clones the NodeBB repository from the v1.9.x
branch to the directorynodebb
.
$ git clone -b v1.9.x 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-get install nginx
Configuring nginx
Create nginx configuration file:
$ sudo vim /etc/nginx/conf.d/nodebb.conf
Then add content:
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.