Hello Everyone,
NodeBB is a next-generation discussion platform powered by Node.js. It’s designed for modern web interactions and real-time notifications.
I tested this out today and thought I may as well post the basic steps to get NodeBB running on Opalstack. The jury is still out regarding long term memory usage/performance, but the base install felt very snappy to me.
The NodeBB instructions state you can use either MongoDB or Redis for the database. Redis is pre-installed and might be easier to setup. More details on how you might use it here.
But to show steps for the alternative, I will be using MongoDB for this guide as we already have a helpful tutorial for it.
First, we have to set that up with users for NodeBB. Here is me re-iterating much of that guide with some updates to sources and new user steps.
- Create a new proxy port app for MongoDB (here I will use mongodb) from the dashboard and note the assigned port number. Additional inline instructions are prefixed by the hash symbol (#) and every other line is a command.
#Setup MongoDB
cd ~/apps/mongodb
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-7.0.7.tgz
tar zxf mongodb-linux-x86_64-rhel70-7.0.7.tgz
ln -s $PWD/mongodb-linux-x86_64-rhel70-7.0.7 mongodb
wget https://downloads.mongodb.com/compass/mongosh-2.2.2-linux-x64.tgz
tar zxf mongosh-2.2.2-linux-x64.tgz
ln -s $PWD/mongosh-2.2.2-linux-x64 mongosh
mkdir data
#Replace 12345 with the assigned port, this will start MongoDB
./mongodb/bin/mongod --dbpath $PWD/data --port 12345 --logpath $HOME/logs/apps/mongodb/mongo.log --pidfilepath $PWD/pid --fork
#Connect to and create your MongoDB superuser, this user is used to manage MongoDB, replace 12345 with the assigned port
~/apps/mongodb/mongosh/bin/mongosh localhost:12345/admin
# you're now in the mongo shell, next command creates your mongo superuser
# replace USERNAME and PASSWORD with your desired mongo username and pw
db.createUser({user: "USERNAME", pwd: "PASSWORD", roles: [ "root" ]})
# verify that it was created
show users
# then exit
exit
#Stop the running mongodb process and restart it with auth enabled, replace 12345 with the assigned port
kill $( cat $HOME/apps/mongodb/pid)
$HOME/apps/mongodb/mongodb/bin/mongod --dbpath $HOME/apps/mongodb/data --port 12345 --logpath $HOME/logs/apps/mongodb/mongo.log --pidfilepath $HOME/apps/mongodb/pid --fork --auth
#Connect to MongoDB, replace USERNAME here with the superuser one we made above and auth with the password, replace 12345 with the assigned port
~/apps/mongodb/mongosh/bin/mongosh localhost:12345/admin --username USERNAME
#Switch to a db
use nodebb
#Create new MongoDB user for NodeBB, replace USERNAME and PASSWORD with new credentials that are different than what you chose before, this is the user we will use when installing NodeBB. Copy all of the below and paste into command line at once and enter.
db.createUser({
user: "USERNAME",
pwd: "PASSWORD",
roles: [
{ role: "readWrite", db: "nodebb" },
{ role: "dbAdmin", db: "nodebb" }
]
});
As noted earlier, to stop and start MongoDB:
#Stop the running MongoDB process
kill $( cat $HOME/apps/mongodb/pid)
#Start MongoDB, replace 12345 with the assigned port
$HOME/apps/mongodb/mongodb/bin/mongod --dbpath $HOME/apps/mongodb/data --port 12345 --logpath $HOME/logs/apps/mongodb/mongo.log --pidfilepath $HOME/apps/mongodb/pid --fork --auth
- Create another proxy port app for NodeBB (here I will use nodebb) from the dashboard and note the assigned port number. You then MUST create a new site record and assign this app to it with your chosen domain that you will use below when installing NodeBB.
#Download and setup nodebb
cd ~/apps/nodebb
git clone -b v2.x https://github.com/NodeBB/NodeBB nodebb
cd nodebb/
scl enable nodejs20 -- ./nodebb setup
#Eventually it will ask you some important setup questions. Answer in similar fashion when you see the following
#Enter the domain you assigned the nodebb app to, preferably using https://, ignore the port in the example below
URL used to access this NodeBB (http://localhost:4567)
#Press enter when you see something like this
Please enter a NodeBB secret (c25246ef-b025-47f2-b5db-a479c8fb8e3e)
#Press enter or type no and enter
Would you like to submit anonymous plugin usage to nbbpm? (yes)
#Press enter
Which database to use (mongo)
#Press enter
MongoDB connection URI: (leave blank if you wish to specify host, port, username/password and database individually)
Format: mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
#Press enter
Host IP or address of your MongoDB instance (127.0.0.1)
#Replace 12345 with the assigned MongoDB port from earlier
Host port of your MongoDB instance (27017) 12345
#Press enter
MongoDB username nodebb
#Enter the PASSWORD you made for the nodebb MongoDB user earlier
Password of your MongoDB database
#Press enter
MongoDB database name (nodebb)
#It will then ask you to create a nodebb user that you will use to login to the website admin area, replace those below and enter password twice
Administrator username USERNAME
Administrator email address YOUREMAIL
Password
Confirm Password
To start/stop NodeBB, you can execute the following (specifying the port in the config.json might work better for you here, and there are different ways to interact with node via scl, so this is just an example):
#Start the nodebb app with the following command, replace 12345 with the assigned nodebb port from earlier
PORT=12345 scl enable nodejs20 -- ~/apps/nodebb/nodebb/nodebb start
#Stop command is similar
PORT=12345 scl enable nodejs20 -- ~/apps/nodebb/nodebb/nodebb stop
And that should be it! The NodeBB app should now be accessible to whatever you set for the working URL and you can login with the user made during the setup. Some will want to manage the processes better with things like Supervisor; or other, so I will leave that open for you to decide what works best for your projects.