Red Hat/Cent OS
If you notice any mistakes that need to be corrected, please reach out on Discord!

MongoDB

Petio supports two ways of connecting to a Mongo Database instance, locally or remote. We recommend the locally hosted MongoDB option.

MongoDB Locally

  • Configure the package management system (yum)
  • Create a /etc/yum.repos.d/mongodb-org-4.4.repo file so that you can install MongoDB directly using yum:
1
sudo nano /etc/yum.repos.d/mongodb-org-4.4.repo
Copied!
  • Paste in the nano / terminal window:
1
[mongodb-org-4.4]
2
name=MongoDB Repository
3
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
4
gpgcheck=1
5
enabled=1
6
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
Copied!
  • Press: "CTRL + O" to save and "CTRL+X" to exit.
  • To install the latest stable version of MongoDB, issue the following command:
1
sudo yum install -y mongodb-org
Copied!
  • Start MongoDB:
1
sudo systemctl start mongod
Copied!
  • Verify that MongoDB has started successfully:
1
sudo systemctl status mongod
Copied!
  • To make sure MongoDB starts after restart use:
1
sudo systemctl enable mongod
Copied!

MongoDB Locally - On A Different Host

By default, MongoDB doesn’t allow remote connections.
  • Locate your mongod.conf and edit it with your favorite editor. Include any local IP addresses you want to allow to connect to your MongoDB instance.
1
vim /etc/mongod.conf
2
# /etc/mongod.conf
3
# Listen to local and LAN interfaces.
4
bind_ip = 127.0.0.1,192.168.161.100
Copied!
  • Restart the mongod service after making these changes
1
sudo systemctl restart mongod
Copied!
If there is a firewall, you might need to use iptables to allow access to MongoDB. Example below:
  • Any connections can connect to MongoDB on port 27017
1
iptables -A INPUT -p tcp --dport 27017 -j ACCEPT
Copied!
  • Only certain IPs can connect to MongoDB on port 27017
1
iptables -A INPUT -s <ip-address> -p tcp --destination-port 27017 -m state --state NEW,ESTABLISHED -j ACCEPT
2
iptables -A OUTPUT -d <ip-address> -p tcp --source-port 27017 -m state --state ESTABLISHED -j ACCEPT
Copied!

MongoDB Remotely

  • Register for Atlas here.
  • Create a free cluster.
  • Change the provider or region if you need to. It may take some time to create the cluster.
  • After the cluster is made, click on connect and select MongoDB Compass and follow the instructions on screen.

Installing Petio

  • Create a user for Petio:
1
sudo useradd -M --shell=/bin/false petio
Copied!
  • Make a directory for Petio:
1
sudo mkdir /opt/Petio
Copied!
  • Download the latest version of Petio:
1
sudo wget https://petio.tv/releases/latest -O petio-latest.zip
Copied!
  • Extract Petio to the directory we just made:
1
sudo unzip petio-latest.zip -d /opt/Petio
Copied!
  • Change ownership of the directory for Petio:
1
sudo chown -R petio:petio /opt/Petio
Copied!
  • Create the petio service with systemd:
1
sudo vi /etc/systemd/system/petio.service
2
3
[Unit]
4
Description=Petio a content request system
5
After=network.target
6
StartLimitIntervalSec=0
7
8
[Service]
9
Type=simple
10
Restart=on-failure
11
RestartSec=1
12
ExecStart=/opt/Petio/bin/petio-linux
13
User=petio
14
15
[Install]
16
WantedBy=multi-user.target
Copied!
  • Reload systemd:
1
sudo systemctl daemon-reload
Copied!
  • Start Petio:
1
sudo systemctl start petio
Copied!
Once you've completed theses steps, you can navigate to http://<hostname>:7777 to start configuring Petio.