NodeBB

https://docs.nodebb.org/installing/os/ubuntu/

Installing Node.js

Install NVM

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

Install Node.js

nvm install node

Test Node.js

nvm -v
node -v
npm -v

node -e "console.log('Running Node.js ' + process.version)"

Installing MongoDB

Import the public key used by the package management system.

wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -

Create a list file for MongoDB

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list

Reload local package database

sudo apt-get update

Install the MongoDB packages

sudo apt-get install -y mongodb-org

Verify installation of MongoDB

mongod --version

Start MongoDB

sudo systemctl start mongod

Verify that MongoDB has started successfully

sudo systemctl status mongod

You can optionally ensure that MongoDB will start following a system reboot

sudo systemctl enable mongod

Configure MongoDB

mongo

Switch to the built-in admin database:

use admin

Create an administrative user:

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

This user is scoped to the admin database to manage MongoDB once authorization has been enabled.

Add a new database called nodebb:

use nodebb

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" } ] } )

Exit the Mongo Shell:

quit()

Enable database authorization in the MongoDB configuration file

/etc/mongod.conf
security:
  authorization: enabled

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

sudo systemctl restart mongod
mongo -u admin -p your_password --authenticationDatabase=admin

Installing NodeBB

First, we must install git as it is used to distribute NodeBB:

sudo apt-get install -y git
git clone -b v1.16.x https://github.com/NodeBB/NodeBB.git nodebb
cd nodebb
./nodebb setup
./nodebb start

Installing Nginx

NodeBB by default runs on port 4567, meaning that by default you must access it using a port number in addition to the hostname (e.g. http://example.org:4567)

In order to allow NodeBB to be served without a port, Nginx can be set up to proxy all requests to a particular hostname (or subdomain) to an upstream NodeBB server running on any port.

sudo apt-get install -y nginx

Verify the installation of Nginx

nginx -v

Run Nginx

sudo systemctl start nginx
sudo systemctl status nginx

Configuring Nginx

NGINX-served sites are contained in a server block which are normally stored in separate files from the main Nginx config (which is very rarely edited).

When installing with the ppa above, the best way to install new Nginx configs is to add new files in /etc/nginx/sites-available (like /etc/nginx/sites-available/forum.example.org). You then must link these files from sites-available to sites-enabled.

The following demonstrates a typical series of commands when creating a new nginx config:

cd /etc/nginx/sites-available
sudo vim forum.example.com # config entered into file and saved
/etc/nginx/sites-available/forum.example.com
server {
    listen 80;

    server_name forum.example.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";
    }
}
cd ../sites-enabled
sudo ln -s ../sites-available/forum.example.com
sudo systemctl reload nginx

Last updated

Was this helpful?