NodeBB is free and open source community forum software. It is written in Node.js and uses Redis or MongoDB to store the data. NodeBB has a modern look and it is completely responsive. It comes with all the features of community forums along with social media integration. It uses web sockets for instant interaction and real-time notifications. The features of the application can be further increased by using themes and plugins.
In this tutorial, we will be installing NodeBB forum on CentOS 7.
NodeBB does not require any special hardware requirements. It can be installed on servers with a small amount of RAM. But the requirement of RAM increases as the user increases. All the required dependencies will be installed throughout the tutorial. You will need a minimal installation of CentOS 7 with root access on it. If you are logged in as a non-root user, you can run sudo -i to switch to root user.
Before installing any package it is recommended that you update the packages and repository using the following command.
yum -y update
Now you will need to install EPEL repository as we will need to install few packages which are not available in the default yum repository. Run the following command to install EPEL repository.
yum -y install epel-releaseyum -y update
Now you will need to install the Development Tools which will install the required tools for compile and build the source code. Run the following command for same.
yum -y groupinstall "Development Tools"
Now install the software stack required for NodeBB using following command.
yum -y install git redis ImageMagick
The above command will install git, redis, and ImageMagick. Now install the latest version of Node.js from the nodesource repository using the following commands.
Once Node.js is installed, you can start Redis and enable it to start at boot time using following commands.
systemctl start redissystemctl enable redis
Now you will need to clone the setup files from NodeBB repository to your server. In this tutorial, we will use /var/nodebb directory to install NodeBB. You can also choose a different path. To create a new directory to install NodeBB, run the following command.
mkdir /var/nodebbcd /var/nodebb
Now clone the NodeBB files into the current directory using the following commands.
git clone https://github.com/NodeBB/NodeBB.git .
Once the software is cloned, you can install all the dependencies required by NodeBB using following command.
If you get any error during the execution of the above command, it is likely that node-gyp is not installed, run the following command to install node-gyp and fix the error.
The above command could take some time to download and install the dependencies. Once done, run the following command to initialize the setup script and start the installer.
Now you will need to answer few questions asked by the installer. It will ask you about the URL for your NodeBB installation, just press enter to use the default value. Further, it will ask you about the NodeBB secret, just press to use the default value. Next, it will ask you which database to use, enter redis and press enter.
The installer will now start to configure Redis. Press enter to use the default value for IP address, port, administrator password and database for Redis instance.
Finally, it will ask you to provide the information for the administrator. Provide a username, email, and password of the administrator.
The output of the script will look as shown below. Log messages are removed from the output.
[root@liptan-pc nodebb]# ./nodebb setup
Welcome to NodeBB!
This looks like a new installation, so you'll have to answer a few questions about your environment before we can proceed.
Press enter to accept the default setting (shown in brackets).
URL used to access this NodeBB (http://localhost:4567)
Please enter a NodeBB secret (afa37197-712f-474a-88ff-e722a041aa40)
Which database to use (mongo) redis
Host IP or address of your Redis instance (127.0.0.1)
Host port of your Redis instance (6379)
Password of your Redis database
Which database to use (0..n) (0)
Configuration Saved OK
Populating database with default configs, if not already set...
NodeBB Setup Completed. Run './nodebb start' to manually start your NodeBB server.
If you provide any incorrect values during the setup, you can restart the setup by executing the above command again, but you will need to remove the configuration file using rm /var/nodebb/config.json. You can also edit the configuration file using a text editor.
To immediately start the forum, run the following command.
Although it is best practice to run the NodeBB server on localhost listening on port 4567, and create a reverse proxy with Apache or nginx to serve the site on the internet. Also instead of running NodeBB server using commands, it is recommended to create a systemd service so that the application can be started automatically on crashes and boot time. To create a systemd service for NodeBB you will need to create a new service file using the following command.
If you do not have nano installed, you can run yum -y install nano. Now paste the following text into the nano editor.
Now you can start NodeBB server and configure it to automatically start at boot time using following commands.
systemctl start nodebbsystemctl enable nodebb
To check if the NodeBB service is started correctly, you can run the following command to check the status of the NodeBB service.
systemctl status nodebb
Configuring nginx as Reverse Proxy with Let's Encrypt SSL
Instead of using the application on Port 4567, you can use nginx to run on port 80 or 443 in the case of using SSL. This way the main application will run on port 4567, and nginx will work as a reverse proxy. Install nginx web server with the following command.
yum -y install nginx
Now we will need to generate SSL certificates from Let's Encrypt client. If you can want to use commercial SSL certificates instead, you can purchase SSL certificates from HostPresto.
To install Let's Encrypt client also called Certbot run the following command.
yum -y install certbot
Once the installation finishes, run the following command to obtain the SSL certificates from Let's Encrypt. Make sure that your domain is pointed to the server, the Let's Encrypt will check the domain authority before providing the certificates. Make sure that you do not have nginx running at this moment.
This command will run Let's Encrypt client to obtain the certificates only but will not install it. --standalone tells the client to use the standalone web server for authentication of domain authority. -d yourdomain.com tells the domain name for which the certificates needs to be obtained. Provide your email address and accept the terms and conditions. Once the certificates are generated, they are likely to be stored in the following directory.
Where yourdomain.com is your actual domain. In the directory, you will find cert.pem which is your domains certificate and privkey.pem which is your certificate's private key.
Let's Encrypt SSL expires in 90 days, so it is recommended to set an automatic renewal for your certificates. Run the following command to open your crontab file.
crontab -e Enter the following line into the crontab file.
In the above configuration change yourdomain.com to your actual domain. Also, make sure that the path to your SSL certificate and private key are correct. Now start nginx web server and enable it to automatically start at boot time using the following commands.
systemctl start nginxsystemctl enable nginx
Now you will need to disable your SELinux because NodeBB does not work with SELinux policies. To temporary disable SELinux without restarting the server, run the following command.
To completely disable the SELinux you will need to edit/etc/selinux/config file.
If you don't have nano installed, you can install it using yum -y install nano Find the following line:
Change it to:
Now you will need to reboot your server so that the new configuration can take effect. Now you can start the NodeBB service if not started already using the following command.
systemctl start nodebb
You can now browse the following URL in your favorite browser.
Looking for the right web hosting solution for your website can be an intimidating task. Options nowadays are more diversified than ever, and each year brings new developments in the web hosting market. If you have no clue of what to look out for, you can find yourself overwhelmed with...
Content marketing continues to be one of the most valuable tools for today’s online businesses. With content, you can improve your chances of reaching your target audience, boost your search engine standing, and even unlock new opportunities for sales. The more content you produce, the more you can strengthen your...
User Experience (UX) is one of the most crucial factors to consider in web design. As the number of websites and applications in the world today continues to accelerate, businesses are under more pressure than ever to impress customers straight away. If a user visits your website and finds slow-loading...