Debian 10/Ubuntu 20.04
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

Make sure to add the correct repository to apt depending on whether you're using Debian or Ubuntu.
  • Import the public key used by the package management system:
1
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
Copied!
  • Create the /etc/apt/sources.list.d/mongodb-org-4.4.list file:
Debian 10
Ubuntu 20.04
1
echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
Copied!
1
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
Copied!
  • Reload local package database:
1
sudo apt-get update
Copied!
  • Install the MongoDB packages:
1
sudo apt-get 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:
/etc/systemd/system/petio.service
1
[Unit]
2
Description=Petio a content request system
3
After=network.target
4
StartLimitIntervalSec=0
5
6
[Service]
7
Type=simple
8
Restart=on-failure
9
RestartSec=1
10
ExecStart=/opt/Petio/bin/petio-linux
11
User=petio
12
13
[Install]
14
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.