This guide will go over the basics of installing NodeBB on an Ubuntu LTS based VPS/dedicated server. I strongly suggest using Ubuntu 24.04LTS as one install I attempted on 22.40LTS had some dependency issues.
It will not cover actual Linux OS setup, as I assume if you have wanting to install NodeBB you will already be familiar with the process of setting up your VPS/dedicated server and configuring it.
Again, I suggest using Ubuntu 24.04LTS because the documentation relating to installing NodeBB on Ubuntu is more detailed than for CentoOS/AlmaLinux/Rocky Linux.
NOTE! You will see me using sudo in some of the commands even after I said to change over to the root user. This is just a safety precaution in case you forget.
If you are not comfortable setting up your VPS or operating in a shell and using CLI, then I would actively encourage you to engage someone that does this for living to assist you.
You should have a minimum of 1GB RAM for your system. If you are using it on a low memory VPS it is assumed you have also already set up a swap for it. If not, you need to do so.
Installing Node.js
Since NodeBB usesNode.js instead of PHP, you will need to install node.js onto your server.
The installation of the current LTS version of Node.js is strongly suggested as it causes less problems for future updates.
You will be downloading a script during this setup using curl. These instructions assume you know how to run the script from the CLI.
Enter the following commands on the CLI of your terminal shell.
When you run the above script it should install the repository information for Node.js along with a few other items of importance that may not have been installed.
Use the following commands to now install it.
Verify installation of Node.js and npm. You should have version 22.13.0 of Node.js installed (as of January 10, 2025), and version 10 of npm installed:
npm should put out output "10.9.2" or similar.
I suggest using the MongoDB instead of Redis or PostgreSQL. It is what is recommended by the NodeBB developers and I figure they know beset. Since I did not use Redis or PostgreSQL so I can not comment on them.
Installing MongoDB
MongoDB is the default (and recommended) database for NodeBB. You need to use at least version 8.0 of MongoDB.
This is a quick guide to installing MongoDB v8 on your Ubuntu server.
You now need to verify the installation of MongoDB. You should have version 8.0.
This should return the version.
Now you need to start the mongod service and verify service status. MongoDB should be active.
Configuring MongoDB
Administration of MongoDB is done through the MongoDB Shell
To access the the shell you need to enter the below via the terminal CLI.
You now need to switch to the built-in admin database
You will now need to create an administrative user for MondoDB (this is different from the nodebb user that you will create later). Replace the placeholder Enter a secure password here with your own selected password.
Once you have done this and hit ENTER key you should see the output of
Now you need to create the NodeBB database for use. While still in mongoosh shell you need to enter
The database will be created using the name you input in the YOUR_DATBASE_NAME and you will then be switched to that newly created database. Now you need to create the user for the nodeBB database and assign it the appropriate privileges.
The readWrite permission allows NodeBB to store and retrieve data from the database you assigned to be used for NodeBB.
You now should exit the Mongo Shell
Now it is time to enable database authorization in the MongoDB configuration file /etc/mongod.conf. You need to add the following lines.
Now it is time to restart MongoDB and confirm that the administrative user you created earlier can connect (this is NOT the user you created to use NodeBB with).
To restart MongoDB use
To connect to a MongoDB deployment that requires authentication, use the --username and --authenticationDatabase options. mongosh will prompt you for the password that you created for the administrative user.
If everything is configured the Mongo Shell will connect. Exit the shell with
Installing NodeBB
nodeBB requires the use of git, so you must install as it is used to distribute NodeBB:
SPECIAL NOTE!!! Commands like git and ./nodebb should not be used with root access (sudo or elevated privileges). It will cause problems with different ownership of files NodeBB needs access to. Switch to a non-privileged user before running these commands.
Now you need to clone NodeBB into an appropriate location. Since I installed Ubuntu and there was already a /var/www installed I created a new directory in that path.
I then changed into the /var/www directory and issued
You have now cloned the NodeBB repository from the v3.x branch to the nodebb directory. You can find a list of alternative branches are available in the NodeBB Branches GitHub page if you want to us a different version.
NodeBB ships with a command line utility which allows for several functions. You will use it to setup NodeBB. This installs the modules from npm and then it will enter the setup utilty.
You will then be given a series of questions. The default values are in parentheses.
The default settings are based upon a local server listening on the default
If this is a fresh install (which it should be) then you will need to set up aforum administrator. Enter the administrator information you wish to use. This is what you will log into your forum with initially.
Pay special attention when entering your site URL. You need to make sure it is exactly what you plan on accessing your site at. If your site is HTTPS://mysite.org then that is what you need to enter. Do NOT use the IP address of your server instance. Also, I found that I did NOT want to put the port number on the URL in the .JSON file as it caused issues. NodeBB knows the default port it runs on so there is no need to put it here. If you are going to run on other than the default port, you can use the PORT parameter in the JSON file.
A configuration file config.json is then created in the root of the nodebb directory.You can then make changes to it if you need to change the database location or credentials used to access the database.
Now you can use the CLI to start NodeBB.
To give the best performance and to keep from having to either place the port number after the domain on your browser it is recommended to place a proxy in front of it. I chose to use nginx as it is what I am somewhat familiar with. You can also use Apache if you are more familiar with it, but this guide will not cover that.
So, if you do want to use a proxy (again, which I strongly recommend) you need to install nginx on your Ubuntu server.
Next post will be for the nginx proxy.
It will not cover actual Linux OS setup, as I assume if you have wanting to install NodeBB you will already be familiar with the process of setting up your VPS/dedicated server and configuring it.
Again, I suggest using Ubuntu 24.04LTS because the documentation relating to installing NodeBB on Ubuntu is more detailed than for CentoOS/AlmaLinux/Rocky Linux.
NOTE! You will see me using sudo in some of the commands even after I said to change over to the root user. This is just a safety precaution in case you forget.
If you are not comfortable setting up your VPS or operating in a shell and using CLI, then I would actively encourage you to engage someone that does this for living to assist you.
You should have a minimum of 1GB RAM for your system. If you are using it on a low memory VPS it is assumed you have also already set up a swap for it. If not, you need to do so.
Installing Node.js
Since NodeBB usesNode.js instead of PHP, you will need to install node.js onto your server.
The installation of the current LTS version of Node.js is strongly suggested as it causes less problems for future updates.
You will be downloading a script during this setup using curl. These instructions assume you know how to run the script from the CLI.
Enter the following commands on the CLI of your terminal shell.
Bash:
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
curl -fsSL https://deb.nodesource.com/setup_lts.x -o nodesource_setup.sh
Use the following commands to now install it.
Bash:
sudo -E bash nodesource_setup.sh
sudo apt-get install -y nodejs
Verify installation of Node.js and npm. You should have version 22.13.0 of Node.js installed (as of January 10, 2025), and version 10 of npm installed:
Bash:
node -v
npm -v
I suggest using the MongoDB instead of Redis or PostgreSQL. It is what is recommended by the NodeBB developers and I figure they know beset. Since I did not use Redis or PostgreSQL so I can not comment on them.
Installing MongoDB
MongoDB is the default (and recommended) database for NodeBB. You need to use at least version 8.0 of MongoDB.
This is a quick guide to installing MongoDB v8 on your Ubuntu server.
Bash:
sudo apt-get install gnupg curl
curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \
sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg \
--dearmor
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
You now need to verify the installation of MongoDB. You should have version 8.0.
Bash:
mongod --version
Now you need to start the mongod service and verify service status. MongoDB should be active.
Bash:
sudo systemctl start mongod
sudo systemctl status mongod
Configuring MongoDB
Administration of MongoDB is done through the MongoDB Shell
mongosh
. The default installation of MongoDB listens on port 27017 and is accessible locally.To access the the shell you need to enter the below via the terminal CLI.
Bash:
mongosh
use admin
You will now need to create an administrative user for MondoDB (this is different from the nodebb user that you will create later). Replace the placeholder Enter a secure password here with your own selected password.
db.createUser( { user: "admin", pwd: "ENTER A SECURE PASSWORD HERE>", roles: [ { role: "root", db: "admin" } ] } )
Once you have done this and hit ENTER key you should see the output of
ok: 1
. This user can now be used to the access/control the admin database to manage MongoDB once authorization has been enabled.Now you need to create the NodeBB database for use. While still in mongoosh shell you need to enter
use YOUR_DATABASE_NAME
The database will be created using the name you input in the YOUR_DATBASE_NAME and you will then be switched to that newly created database. Now you need to create the user for the nodeBB database and assign it the appropriate privileges.
db.createUser( { user: "YOUR_DB_USER_NAME_TO_USE", pwd: "ENTER_A_SECURE_PASSWORD", roles: [ { role: "readWrite", db: "YOUR_DATABASE_NAME" }, { role: "clusterMonitor", db: "admin" } ] } )
The readWrite permission allows NodeBB to store and retrieve data from the database you assigned to be used for NodeBB.
You now should exit the Mongo Shell
quit()
Now it is time to enable database authorization in the MongoDB configuration file /etc/mongod.conf. You need to add the following lines.
Code:
security:
authorization: enabled
Now it is time to restart MongoDB and confirm that the administrative user you created earlier can connect (this is NOT the user you created to use NodeBB with).
To restart MongoDB use
Bash:
sudo systemctl restart mongod
To connect to a MongoDB deployment that requires authentication, use the --username and --authenticationDatabase options. mongosh will prompt you for the password that you created for the administrative user.
Bash:
mongosh "mongodb://localhost:27017" --username admin --authenticationDatabase admin
quit()
.Installing NodeBB
nodeBB requires the use of git, so you must install as it is used to distribute NodeBB:
Bash:
sudo apt-get install -y git
Now you need to clone NodeBB into an appropriate location. Since I installed Ubuntu and there was already a /var/www installed I created a new directory in that path.
I then changed into the /var/www directory and issued
Bash:
git clone -b v3.x https://github.com/NodeBB/NodeBB.git nodebb
cd nodebb
NodeBB ships with a command line utility which allows for several functions. You will use it to setup NodeBB. This installs the modules from npm and then it will enter the setup utilty.
Bash:
./nodebb setup
The default settings are based upon a local server listening on the default
port 4567
with a MongoDB instance listening on port 27017
. When prompted for the mongodb username and password, enter the nodeBB database username you created earlier (not the admin one) and then the password that you set earlier. Once connectivity to the database is confirmed the setup will prompt that initial user setup is running.If this is a fresh install (which it should be) then you will need to set up aforum administrator. Enter the administrator information you wish to use. This is what you will log into your forum with initially.
Pay special attention when entering your site URL. You need to make sure it is exactly what you plan on accessing your site at. If your site is HTTPS://mysite.org then that is what you need to enter. Do NOT use the IP address of your server instance. Also, I found that I did NOT want to put the port number on the URL in the .JSON file as it caused issues. NodeBB knows the default port it runs on so there is no need to put it here. If you are going to run on other than the default port, you can use the PORT parameter in the JSON file.
A configuration file config.json is then created in the root of the nodebb directory.You can then make changes to it if you need to change the database location or credentials used to access the database.
Now you can use the CLI to start NodeBB.
Bash:
./nodebb start
So, if you do want to use a proxy (again, which I strongly recommend) you need to install nginx on your Ubuntu server.
Next post will be for the nginx proxy.
Last edited: