{"id":30529,"date":"2019-05-20T13:12:34","date_gmt":"2019-05-20T18:12:34","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=30529"},"modified":"2022-06-03T03:34:06","modified_gmt":"2022-06-03T08:34:06","slug":"how-to-install-nodebb-on-debian-9","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-install-nodebb-on-debian-9\/","title":{"rendered":"How to Install NodeBB on Debian 9"},"content":{"rendered":"
<\/p>\n
In this tutorial, we will show you how to install NodeBB on Debian 9, NodeBB is a free and open-source discussion platform that utilizes web sockets for instant interactions and real-time notifications. Powered by Node.js, NodeBB is fast, simple, and easy-to-use. It has lots of features, such as social network integration and streaming discussions.\u00a0<\/p>\n
The very first step in this tutorial is to log in to your Debian 9 VPS as the root user (or as a system administrator) via SSH<\/p>\n
ssh root@IP_Address<\/span> -p Port_number<\/span><\/pre>\nreplace ‘IP_Address<\/span>‘ and ‘Port_number<\/span>‘ with the respective IP address and SSH port number that your server uses.<\/p>\nOnce you are logged in, run the following command to make sure that all installed packages on your server are updated to the latest available version:<\/p>\n
apt update && apt upgrade<\/pre>\nStep 2: Install Node.js<\/strong><\/h2>\nAs we mentioned earlier, NodeBB is powered by Node.js, so we’ll have to install Node.js and the npm<\/code> package manager onto our server. To do that, we have to install the NodeSource Node.js repository first, as it is not a pre-installed software repository.<\/p>\napt install curl<\/pre>\ncurl -sL https:\/\/deb.nodesource.com\/setup_10.x | sudo -E bash -<\/pre>\nOnce the repository is added, we can go ahead and install Node.js and npm. We will also need the development tools in order to build native addons.<\/p>\n
apt install -y nodejs gcc g++ make<\/pre>\nAfter the installation is completed, check the installed versions of Node.js and npm.<\/p>\n
For Node.js, run:<\/p>\n
node -v\r\nv10.15.3<\/pre>\nIn order to check the npm version, run this:<\/p>\n
node -v\r\n6.4.1<\/pre>\nStep 3: Install MongoDB Database Server<\/strong><\/h2>\nNodeBB uses MongoDB as its default database server, so the next requirement is to install the MongoDB database server from MongoDB’s official repository. To begin, we will execute the following command to import the MongoDB public key. This ensures package consistency and authenticity.<\/p>\n
apt-key adv --keyserver hkp:\/\/keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4<\/pre>\nOutput:<\/p>\n
Executing: \/tmp\/apt-key-gpghome.GX3VagKFsu\/gpg.1.sh --keyserver hkp:\/\/keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4\r\ngpg: key 68818C72E52529D4: public key \"MongoDB 4.0 Release Signing Key <packaging@mongodb.com>\" imported\r\ngpg: Total number processed: 1\r\ngpg: imported: 1<\/pre>\nAdd the official MongoDB repository by creating a \u2018\/etc\/apt\/sources.list.d\/mongodb-org-4.0.list\u2019 file using the following command:<\/p>\n
echo \"deb http:\/\/repo.mongodb.org\/apt\/debian stretch\/mongodb-org\/4.0 main\" | sudo tee \/etc\/apt\/sources.list.d\/mongodb-org-4.0.list<\/pre>\nNow, update the local package database and install MongoDB:<\/p>\n
apt update && apt install mongodb-org<\/pre>\nOnce the installation of MongoDB has been completed, start the MongoDB service and enable it to start upon a reboot:<\/p>\n
systemctl start mongod\r\nsystemctl enable mongod\r\n<\/pre>\nYou can also check its status by issuing the following command:<\/p>\n
systemctl status mongod<\/pre>\nOutput:<\/p>\n
\tmongod.service - MongoDB Database Server\r\n Loaded: loaded (\/lib\/systemd\/system\/mongod.service; enabled; vendor preset: enabled)\r\n Active: active (running) since Fri 2019-04-19 07:39:09 EDT; 16s ago\r\n Docs: https:\/\/docs.mongodb.org\/manual\r\n Main PID: 14793 (mongod)\r\n CGroup: \/system.slice\/mongod.service\r\n \u00e2\u00e214793 \/usr\/bin\/mongod --config \/etc\/mongod.conf\r\n<\/pre>\nStep 4: Create a Database for NodeBB<\/strong><\/h2>\nWe now have our MongoDB server installed and running – therefore, the next thing we need to do is to create a MongoDB database and user through the MongoDB Shell for our NodeBB installation. Run through the following commands to access the shell and switch to the built-in admin database:<\/p>\n
mongo\r\nuse admin<\/pre>\nThen create an admin user.<\/p>\n
db.createUser( { user: \"admin\", pwd: \"PASSWORD<\/span>\", roles: [ { role: \"root\", db: \"admin\" } ] } )<\/pre>\nRemember to replace\u00a0PASSWORD<\/span>\u00a0with a strong password.<\/p>\nOnce the administrative user is created, we then proceed with creating a database for NodeBB. It can be easily done using the ‘use’ command<\/p>\n
use nodebb<\/pre>\nNext, create a nodebb database user with the necessary privileges:<\/p>\n
db.createUser( { user: \"nodebb\", pwd: \"NODEBBPASSWORD<\/span>\", roles: [ { role: \"readWrite\", db: \"nodebb\" }, { role: \"clusterMonitor\", db: \"admin\" } ] } )<\/pre>\nAnd again, don’t forget to replace ‘NODEBBPASSWORD<\/span>‘ with an actual password.<\/p>\nFinally, exit the MongoDB Shell using the following command:<\/p>\n
quit()<\/pre>\nModify the MongoDB configuration to enable database authorization, as shown below:<\/p>\n
nano \/etc\/mongod.conf\r\n\r\nsecurity:\r\n authorization: enabled<\/pre>\nRestart the MongoDB server for the changes to take effect:<\/p>\n
systemctl restart mongod<\/pre>\nStep 5: Install NodeBB<\/strong><\/h2>\nNow that we have all the requirements installed and configured, we can finally download and install NodeBB on the server. First, we need to create a directory for the NodeBB installation:<\/p>\n
mkdir -p \/var\/www\/html\/nodebb<\/pre>\nClone the NodeBB repository from the v1.11.x branch.<\/p>\n
git clone -b v1.11.x https:\/\/github.com\/NodeBB\/NodeBB.git<\/pre>\nOnce the repository is cloned, run the setup script provided by NodeBB to install some required modules:<\/p>\n
cd nodebb && .\/nodebb setup<\/pre>\nDuring the setup, you will be prompted to answer several questions. After the setup is completed, the NodeBB installation will be ready to use. You can start it with the following command.<\/p>\n
.\/nodebb start<\/pre>\nStep 6: Install and Configure Nginx<\/strong><\/h2>\nIn order to be able to access NodeBB with a domain name instead of using the IP address and the port number, we have to install the Nginx web server and set up a reverse proxy.<\/p>\n
To install the Nginx web server, run this command:<\/p>\n
apt install nginx<\/pre>\nAfter the installation has completed, start the web server and enable it to automatically start after a server restart:<\/p>\n
systemctl start nginx\r\nsystemctl enable nginx<\/pre>\nCreate an Nginx virtual block directive for your domain name. We will use mydomain.com<\/span> as a domain name.<\/p>\n\/etc\/nginx\/sites-available\/mydomain.com<\/span>.conf\r\n\r\nserver {\r\n listen 80;\r\n\r\n server_name mydomain.com<\/span>;\r\n\r\n location \/ {\r\n proxy_set_header X-Real-IP $remote_addr;\r\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n proxy_set_header X-Forwarded-Proto $scheme;\r\n proxy_set_header Host $http_host;\r\n proxy_set_header X-NginX-Proxy true;\r\n\r\n proxy_pass http:\/\/127.0.0.1:4567;\r\n proxy_redirect off;\r\n\r\n # Socket.IO Support\r\n proxy_http_version 1.1;\r\n proxy_set_header Upgrade $http_upgrade;\r\n proxy_set_header Connection \"upgrade\";\r\n }\r\n}\r\n<\/pre>\nSave the changes and enable the virtual block directive:<\/p>\n
ln -s \/etc\/nginx\/sites-available\/yourdomain.conf \/etc\/nginx\/sites-enabled\/<\/pre>\nRestart the Nginx web server for the changes to take effect.<\/p>\n
systemctl restart nginx<\/pre>\nWith this step, the installation and configuration of NodeBB on your Debian 9 server is now complete. You can open your preferred web browser and navigate to http:\/\/mydomain.com<\/code> to access the NodeBB instance.<\/p>\n<\/p>\n
\nOf course, you don\u2019t have to Install NodeBB on Debian 9 if you use one of our Debian VPS Hosting<\/a> services, in which case you can simply ask our expert Linux admins to install the NodeBB forum software for you. They are available 24\u00d77 and will take care of your request immediately.<\/p>\nPS.<\/strong><\/span> If you liked this post on how to Install NodeBB on Debian 9, please share it with your friends on the social networks using the share shortcuts below, or simply leave a comment down in the comments section. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":"In this tutorial, we will show you how to install NodeBB on Debian 9, NodeBB is a free and open-source … <\/p>\n