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 walk you through the step-by-step NodeBB installation process on the Fedora 29 operating system by using Nginx as a reverse proxy, MongoDB as the database and acme.sh and Let's Encrypt for HTTPS.

 

Requirements

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.

 

Prerequisites

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

 

Initial steps

 

Check your Fedora version:

cat /etc/fedora-release
# Fedora release 29 (Twenty Nine)

 

Set up the timezone:

timedatectl list-timezones
sudo timedatectl set-timezone 'Region/City'

 

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 dnf check-upgrade || sudo dnf upgrade -y

 

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

sudo dnf install -y curl wget vim bash-completion git socat

 

For simplicity's sake, disable SELinux and Firewall:

sudo setenforce 0; sudo systemctl stop firewalld.service; sudo systemctl disable firewalld.service

 

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 Fedora repo:

sudo dnf -y install nodejs

 

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

sudo dnf install -y gcc-c++ make
# or
# sudo dnf groupinstall -y 'Development Tools'

 

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.0
# 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 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, issue the following command:

sudo dnf install -y mongodb mongodb-server

 

Check the MongoDB version:

mongo --version | head -n 1 && mongod --version | head -n 1
# MongoDB shell version v4.0.1
# db version v4.0.1

 

Start and enable (set it to start on reboot) MongoDB 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 MongoDB database and user for NodeBB.

 

Connect to MongoDB server first.

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: "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 mongod.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 acme.sh client and obtain Let's Encrypt certificate (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 acme.sh client. Acme.sh is a pure unix shell software for obtaining TLS certificates from Let's Encrypt with zero dependencies. 

 

Download and install acme.sh:

sudo su - root
git clone https://github.com/Neilpang/acme.sh.git
cd acme.sh 
./acme.sh --install --accountemail your_email@example.com
source ~/.bashrc
cd ~

 

Check acme.sh version:

acme.sh --version
# v2.8.0

 

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

# RSA 2048
acme.sh --issue --standalone -d example.com --keylength 2048
# ECDSA
acme.sh --issue --standalone -d example.com --keylength ec-256

 

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

 

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

For RSA: /home/username/example.com directory.

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

 

To list your issued certs you can run:

acme.sh --list

 

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

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

 

Install/copy certificates to /etc/letsencrypt directory.

# RSA
acme.sh --install-cert -d example.com --cert-file /etc/letsencrypt/example.com/cert.pem --key-file /etc/letsencrypt/example.com/private.key --fullchain-file /etc/letsencrypt/example.com/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"
# ECC/ECDSA
acme.sh --install-cert -d example.com --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:

exit

 

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 dnf install -y nginx

 

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

nginx -v
# 1.14.1

 

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 http://example.com:4567, 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;
  
  server_name forum.example.com;
  
  client_max_body_size 50M;

  # RSA
  ssl_certificate /etc/letsencrypt/example.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/example.com/private.key;
  # ECDSA
  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_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 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 https://github.com/NodeBB/NodeBB.git .

 

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 nodebb.service systemd unit config file. This unit file will handle startup of NodeBB deamon. Run sudo vim /etc/systemd/system/nodebb.service and add the below content:

[Unit]
Description=NodeBB
Documentation=https://docs.nodebb.org
After=system.slice multi-user.target mongod.service

[Service]
Type=forking
User=nodebb

StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=nodebb

Environment=NODE_ENV=production
WorkingDirectory=/var/www/nodebb
PIDFile=/var/www/nodebb/pidfile
ExecStart=/usr/bin/env node loader.js
Restart=always

[Install]
WantedBy=multi-user.target

 

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 Fedora 29 system. You should be able to access your forum on your domain and interact with your forum.

 

Hjälpte svaret dig? 0 användare blev hjälpta av detta svar (0 Antal röster)