Installing NodeBB with Mongo on CentOS 7
-
Starting from a standard install of CentOS 7 Minimal r1511.
Update CentOS
yum -y update
Install EPEL and firewalld
yum -y install epel-release firewalld
Start the firewall and enable it to start at boot
systemctl start firewalld systemctl enable firewalld
While we are at it, allow port 4567 (default port for NodeBB) through the firewall
firewall-cmd --zone=public --add-port=4567/tcp --permanent firewall-cmd --reload
Install a couple packages to make life easier
yum -y install nano wget
Install the packages required for NodeBB
yum -y groupinstall "Development Tools" yum -y install git ImageMagick npm
Add the Mongo repo
cat > /etc/yum.repos.d/mongodb-org-3.2.repo <<EOF [mongodb-org-3.2] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/\$releasever/mongodb-org/3.2/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc EOF
Install Mongo
yum install -y mongodb-org policycoreutils-python
Tell SELinux to not stop mongo on its default port as well as NodeBB
semanage port -a -t mongod_port_t -p tcp 27017 semanage port -m -t http_port_t -p tcp 4567
Mongo will have a warning about this setting when launched and suggests you set it to 32000. So do so before we do anything else.
cat >> /etc/security/limits.d/20-nproc.conf <<EOF mongod soft nproc 32000 EOF
Start and enable mongod to start on boot.
systemctl start mongod systemctl enable mongod
Start Mongo
mongo
Create/Switch to the new database you want to use for NodeBB
use nodebb
Create a user for the database
db.createUser( { user: "nodebb", pwd: "somebiglongpassword", roles: [ "readWrite" ] } )
Exit mongo
exit
Edit the mongo config
nano /etc/init.d/mongod
Add
--auth
to the options lineOPTIONS=" --auth -f $CONFIGFILE"
Reload systemd and restart Mongo
systemctl daemon-reload systemctl restart mongod
Run the nvm install script for the current version noted at https://github.com/creationix/nvm/releases
As of the creation of this guide, that version isv0.32.1
curl https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash source ~/.bash_profile
List the available versions to be installed, and install the most recent
As of the creation of this guide that isv7.2.0
nvm list-remote nvm install v7.2.0
Change to the directory you want to have the nodebb folder in
cd /opt
Checkout nodebb from github.
git clone -b v1.x.x https://github.com/NodeBB/NodeBB nodebb
Change into the nodebb directory just created
cd nodebb
Install nodejs
npm install
Start NodeBB with the setup flag.
./nodebb setup
Fill in the fields appropriately for your instance. I already have a Nginx Proxy setup in front of this instance and a FQDN setup. So I populate the URL with that.
30/11 22:39 [56143] - info: NodeBB Setup Triggered via Command Line 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) https://community.yourdomain.com Please enter a NodeBB secret (1234abcd-ef56-7890-a1b1-1234abcd2a1a) Which database to use (mongo) 30/11 22:40 [56143] - info: Now configuring mongo database: Host IP or address of your MongoDB instance (127.0.0.1) Host port of your MongoDB instance (27017) MongoDB username nodebb Password of your MongoDB database somebiglongpassword MongoDB database name (nodebb) Configuration Saved OK 30/11 22:40 [56143] - info: [database] Checking database indices. 30/11 22:40 [56143] - info: [database] Checking database indices done! Populating database with default configs, if not already set... Enabling default theme: nodebb-theme-persona No categories found, populating instance with default categories
It then tells you to create the initial admin user account.
30/11 22:40 [56143] - warn: No administrators have been detected, running initial user setup Administrator username someadminusername Administrator email address [email protected] Password Confirm Password Creating welcome post! Enabling default plugins
Snipped a bunch of messages. Look for the complete message.
NodeBB Setup Completed. Run './nodebb start' to manually start your NodeBB server.
Start your instance
./nodebb start
Open a browser and navigate to your URL.
-
reserved for some post install config.
-
The bit about the admin user has changed somewhere around 1.4. Now it makes a random user for you rather than prompting you to make one.
-
@scottalanmiller said in Installing NodeBB with Mongo on CentOS 7:
The bit about the admin user has changed somewhere around 1.4. Now it makes a random user for you rather than prompting you to make one.
I wrote this against 1.4.0, so either 1.4.1 or 1.4.2 (current).
-
@JaredBusch said in Installing NodeBB with Mongo on CentOS 7:
@scottalanmiller said in Installing NodeBB with Mongo on CentOS 7:
The bit about the admin user has changed somewhere around 1.4. Now it makes a random user for you rather than prompting you to make one.
I wrote this against 1.4.0, so either 1.4.1 or 1.4.2 (current).
I didn't do a raw install of 1.4.1 so no guess there. Just did a 1.4.2 and saw it.
-
@scottalanmiller what would be the best method to launch nodebb on reboot?
I can think of a couple things to do, but what is "best practice" for something like this.
-
@JaredBusch said in Installing NodeBB with Mongo on CentOS 7:
@scottalanmiller what would be the best method to launch nodebb on reboot?
I can think of a couple things to do, but what is "best practice" for something like this.
I'm using the crontab, it's flexible and easy. Since there is no existing boot scripts for NodeBB and it happens after Nginx fires up.
Best practice would really be to write a start up script and add it to the systemctl system. But really, that just seems like overkill to me. Because the system (in my case) is dedicated to NodeBB and all NodeBB instances are listed in a single location, it's incredibly obvious and easy to manage.
-
@scottalanmiller said in Installing NodeBB with Mongo on CentOS 7:
I'm using the crontab, it's flexible and easy. Since there is no existing boot scripts for NodeBB and it happens after Nginx fires up.
what just something like this?
@reboot cd /opt/nodebb && ./nodebb start
@scottalanmiller said in Installing NodeBB with Mongo on CentOS 7:
Best practice would really be to write a start up script and add it to the systemctl system. But really, that just seems like overkill to me. Because the system (in my case) is dedicated to NodeBB and all NodeBB instances are listed in a single location, it's incredibly obvious and easy to manage.
I guess someone should document this process one of these days..
-
@JaredBusch said in Installing NodeBB with Mongo on CentOS 7:
@scottalanmiller said in Installing NodeBB with Mongo on CentOS 7:
I'm using the crontab, it's flexible and easy. Since there is no existing boot scripts for NodeBB and it happens after Nginx fires up.
what just something like this?
@reboot cd /opt/nodebb && ./nodebb start
@scottalanmiller said in Installing NodeBB with Mongo on CentOS 7:
Best practice would really be to write a start up script and add it to the systemctl system. But really, that just seems like overkill to me. Because the system (in my case) is dedicated to NodeBB and all NodeBB instances are listed in a single location, it's incredibly obvious and easy to manage.
I guess someone should document this process one of these days..
Yes, but on my system the folder is not /opt/nodebb but is /opt/sitename so that it is very clear what is starting and what the order is.
-
@scottalanmiller said in Installing NodeBB with Mongo on CentOS 7:
@JaredBusch said in Installing NodeBB with Mongo on CentOS 7:
@scottalanmiller said in Installing NodeBB with Mongo on CentOS 7:
I'm using the crontab, it's flexible and easy. Since there is no existing boot scripts for NodeBB and it happens after Nginx fires up.
what just something like this?
@reboot cd /opt/nodebb && ./nodebb start
@scottalanmiller said in Installing NodeBB with Mongo on CentOS 7:
Best practice would really be to write a start up script and add it to the systemctl system. But really, that just seems like overkill to me. Because the system (in my case) is dedicated to NodeBB and all NodeBB instances are listed in a single location, it's incredibly obvious and easy to manage.
I guess someone should document this process one of these days..
Yes, but on my system the folder is not /opt/nodebb but is /opt/sitename so that it is very clear what is starting and what the order is.
I was following the example listed in this thread. I used
/opt/nodebb
for the instructions -
Note, it apparently detects the previous install and updates with git anyway.
[root@daermabb ~]# curl https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 11329 100 11329 0 0 21219 0 --:--:-- --:--:-- --:--:-- 21255 => nvm is already installed in /root/.nvm, trying to update using git => => Compressing and cleaning up git repository Counting objects: 6072, done. Compressing objects: 100% (6034/6034), done. Writing objects: 100% (6072/6072), done. Total 6072 (delta 4010), reused 1867 (delta 0)
-
This guide does it this way
git clone git://github.com/creationix/nvm.git ~/.nvm printf "\n\n# NVM\nif [ -s ~/.nvm/nvm.sh ]; then\n\tNVM_DIR=~/.nvm\n\tsource ~/.nvm/nvm.sh\nfi" >> ~/.bashrc NVM_DIR=~/.nvm source ~/.nvm/nvm.sh
-
Guess I should update this one of these days
-
@jaredbusch said in Installing NodeBB with Mongo on CentOS 7:
Guess I should update this one of these days
Wow.. I need to write an updated guide...
-
It's a bit different, now.
-
@jaredbusch said in Installing NodeBB with Mongo on CentOS 7:
@jaredbusch said in Installing NodeBB with Mongo on CentOS 7:
Guess I should update this one of these days
Wow.. I need to write an updated guide...
Just remember mongodb and nodejs can be installed natively on Fedora.
https://developer.fedoraproject.org/tech/database/mongodb/about.html
https://developer.fedoraproject.org/tech/languages/nodejs/nodejs.html