installing nodebb tutorial ubuntu 18.04

Painless NGINX NodeBB Installation Tutorial on Ubuntu 18.04

NodeBB is by far the most difficult piece of software I’ve ever configured on a VPS. No single tutorial online had the complete instructions (including NodeBB documentation) and there was always some missing instruction or a piece of information I had to hunt around for. Much of this tutorial follows the NodeBB documentation with a few extra caveats I discovered along the way.

We’ll be installing NodeBB on top of Ubuntu 18.04 LTS using NGINX and MongoDB.

Installing and configuring NGINX

NGINX is required to access NodeBB without specifying a port number. If you don’t mind accessing NodeBB with a port number you can skip this step. For most people running a public forum you’ll want to setup NGINX to proxy web connections to the right port. Let’s install the NGINX web server and create the necessary server blocks.

Install NGINX:

$ sudo apt-get install -y nginx

Like the Apache web server the NGINX configuration files for active sites are stored in /etc/nginx/sites-available. A symlink to these configuration files must be present in /etc/nginx/sites-enabled to activate the configuration.

Create the server block and symlink:

$ cd /etc/nginx/sites-available
$ sudo vi 
$ cd ../sites-enabled
$ sudo ln -s ../sites-available/

Edit server block:

Open up the server block configuration file in any text editor and add the following:

server {


    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";

Reload NGINX

$ sudo systemctl reload nginx

Installing and configuring MongoDB

NodeBB uses the MongoDB database to store information.

Install MongoDB:

$ sudo apt-key adv --keyserver hkp:// --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
$ echo "deb [ arch=amd64 ] bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
$ sudo apt-get update
$ sudo apt-get install -y mongodb-org

Connect to the Mongo shell:


Connect to the built in MongDB admin database:

> use admin

Create an Administrator user:

An administrative user is configured to setup databases. Substitute your own password between the bolded quotes below.

> db.createUser( { user: "admin", pwd: "Enter your password here", roles: [ { role: "root", db: "admin" } ] } )

Create the nodebb database:

> use nodebb

Create a user called nodebb and grant privileges:

Substitute your own password in the snippet below.

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

Exit Mongo shell:

> quit()

Enable authorization in /etc/mongod.conf:

Open up the /etc/mongod.conf file and uncomment the security section or append the following:


  authorization: enabled

!!Warning!! Mongodb does not support tabbed indentation. Use spaces everytime you edit the configuration. Mongdb won’t even start with tabbed indents! Took me an hour to figure this out.

Restart Mongodb:

$sudo service mongodb restart

Installing Node.Js

NodeBB is built on Node.js so we me must install it on the server. This process is quick and painless.

Download and install Node.js:

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

Installing NodeBB

The final step is installing and configuring NodeBB itself. Here we install Git to pull the required files from the Git servers where NodeBB is hosted.

Install Git:

$ sudo apt-get install -y git

Git the NodeBB package:

Change into the directory you want NodeBB installed and execute the following:

$ git clone -b v1.11.x nodebb
$ cd nodebb

Start the setup script:

$ ./nodebb setup

For me, I found the process appeared to hang up and freeze. The NodeBB documentation states that you’ll be asked a series of questions but you’ll actually need to open a browser to complete the installation. Open any browser and navigate to your site to finish setup. Below you’ll see the NodeBB installer page. Fill in the appropriate data being sure to enter the correct username and password for the MongoDB database. The correct username is the second user we created here in this tutorial. (nodebb)

Upon entering in the correct info NodeBB is officially installed and ready to use.

nodebb initial web setup

Troubleshooting FAQ

You will generally find errors hit you right in the face as they happen and don’t allow you to progress. If you successfully made it through this tutorial but still running into problems, here are a few troubleshooting tips.

If your site refuses to load in a browser try accessing through the port eg;

If you’re able to access the installation but only through a port number, NGINX is not properly managing the proxy. Here’s a few troubleshooting steps.

Ensure NGINX service is running:

$sudo service nginx status

If it’s not running attempt a restart:

$service nginx restart

If it refuses to start you’ll generally receive some type of error message from the shell. Look at /var/log/nginx/error.log for further information. Often times syntax errors in configuration files are to blame.

Verify correct syntax in configuration files:

$sudo nginx -t

If there’s an error message NGINX will output the file and the line number causing the issue. Common problems are syntax errors in your server block or broken/non-existent symlinks in /etc/nginx/sites-enabled/

Verify if MongoDB is running and restart if necessary:

$sudo service mongod status
$sudo mongod restart

Verify you can connect to the Mongo shell with the user we created earlier:

$ mongo -u admin -p your_password --authenticationDatabase=admin

Errors running any of these commands warrants investigation into the error logs if the initial output doesn’t indicate anything specific.

Nginx log – /var/log/nginx/error.log

MongoDB log – /var/log/mongodb/mongo.log

Drop a comment below if you have any questions.

Leave a Comment