From 589cdd13bd69ee92208a9a165132faf740339980 Mon Sep 17 00:00:00 2001 From: diamondop1234 Date: Thu, 29 Jul 2021 08:46:10 +0200 Subject: added peertube guide --- peertube.html | 184 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 peertube.html (limited to 'peertube.html') diff --git a/peertube.html b/peertube.html new file mode 100644 index 0000000..ad00d65 --- /dev/null +++ b/peertube.html @@ -0,0 +1,184 @@ + + + + PeerTube Instance – LandChad.net + + + + + + + +

PeerTube Instance

+ +
+ + PeerTube logo + +

PeerTube is a self-hosted and (optionally) federated video sharing platform that saves bandwith on videos the more people watch. + PeerTube instances can follow each other to share videos and grow the federated network, + but you can always keep your instance to yourself if you choose to.

+ +

Prerequisites

+ +

Most of PeerTube's dependencies can be installed with this command:

+ +
apt install curl sudo unzip vim ffmpeg postgresql postgresql-contrib g++ make redis-server git python-dev cron wget
+ +

It's also important to start all associated daemons:

+ +
systemctl start postgresql redis
+ +

PeerTube also requires NodeJS 14 and yarn which cannot be installed from the Debian repositories. This means they have to be installed from separate, external repos:

+ +
curl -fsSL https://deb.nodesource.com/setup_14.x | bash -
+apt-get install -y nodejs
+npm install --global yarn
+ +

In addition to these dependencies, it's recommended to create a dedicated PeerTube user to install and manage PeerTube.

+ +
useradd -m -d /var/www/peertube -s /bin/bash -p peertube peertube
+ +

Database

+ +

PeerTube requires a PostgreSQL database to function. To create it, first make a new Postgres user named PeerTube:

+ +
su postgres
+createuser -P peertube
+createdb -O peertube -E UTF8 -T template0 peertube_prod
+psql -c "CREATE EXTENSION pg_trgm;" peertube_prod
+psql -c "CREATE EXTENSION unaccent;" peertube_prod
+exit
+ +

Be sure to make note of your Postgres user password, as it will be needed later when setting up PeerTube.

+ +

Installation

+ +

This handy one-liner can be used to determine the latest PeerTube version:

+ +
VERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4) && echo "Latest Peertube version is $VERSION"
+ +

Next, a basic directory structure needs to be setup in the PeerTube user's home directory (/var/www/peertube).

+ +

To ensure permissions remain the same while managing files as PeerTube, sudo can be used to perform actions:

+ +
sudo -u peertube mkdir config storage versions
+sudo -u peertube chmod 750 config
+ +

Finally, a PeerTube release can be downloaded from the GitHub page and installed using yarn:

+ +
cd versions
+sudo -u peertube ln -s versions/peertube-${VERSION} ./peertube-latest
+cd ./peertube-latest && sudo -H -u peertube yarn install --production --pure-lockfile
+ +

Configuration

+ +

PeerTube's default config file can be copied over to /var/www/peertube/config.production.yaml so it can actually be used:

+ +
cd /var/www/peertube
+	sudo -u peertube cp peertube-latest/production.yaml config/production.yaml
+ +

Now the production.yaml file must be edited in the following ways:

+ +

First, add the hostname:

+ +
webserver:
+  https: true
+  hostname: 'example.org'
+  port: 443
+ +

Then, the database:

+ +
database:
+  hostname: 'localhost'
+  port: 5432
+  ssl: false
+  suffix: '_prod'
+  username: 'peertube'
+  password: 'your_password'
+  pool:
+     max: 5
+ +

An email to generate the admin user:

+ +
admin:
+  # Used to generate the root user at first startup
+  # And to receive emails from the contact form
+  email: 'chad@example.org'
+ +

And optionally, email server information:

+ +
smtp:
+  # smtp or sendmail
+  transport: smtp
+  # Path to sendmail command. Required if you use sendmail transport
+  sendmail: null
+  hostname: mail.example.org
+  port: 465 # If you use StartTLS: 587
+  username: your_email_username
+  password: your_email_password
+  tls: true # If you use StartTLS: false
+  disable_starttls: false
+  ca_file: null # Used for self signed certificates
+  from_address: 'admin@example.org'
+ +

NGINX

+ +

PeerTube includes an NGINX configuration that can be copied over to /etc/nginx/sites-available: + +

cp /var/www/peertube/peertube-latest/support/nginx/peertube /etc/nginx/sites-available/peertube
+ +

Because the PeerTube config is so long, it's recommended to use sed to modify the contents of the file, + replacing ${WEBSERVER_HOST} with your hostname, + and $(PEERTUBE_HOST) with your localhost and port, which by default should be 127.0.0.1:9000: + +

sed -i 's/${WEBSERVER_HOST}/example.org/g' /etc/nginx/sites-available/peertube
+sed -i 's/${PEERTUBE_HOST}/127.0.0.1:9000/g' /etc/nginx/sites-available/peertube
+ +

Once you're happy with the NGINX config file, link it to sites-enabled to activate it:

+ +
ln -s /etc/nginx/sites-available/peertube /etc/nginx/sites-enabled/peertube
+ +

Encryption with Certbot

+ +

It's highly recommended to generate certificates for use with your PeerTube site, and this can be easily done with Let's Encrypt's certbot command:

+ +
systemctl stop nginx
+certbot certonly --standalone -d example.org
+sudo systemctl restart nginx
+ +

The certificates are generated standalone since the PeerTube NGINX config file already includes configuration for certbot.

+ +

Running PeerTube

+ +

A config file for a systemd daemon is included in PeerTube and can be setup like so:

+ +
cp /var/www/peertube/peertube-latest/support/systemd/peertube.service /etc/systemd/system/
+systemctl daemon-reload
+ +

Now, finally, run the PeerTube daemon to start PeerTube:

+ +
systemctl start peertube
+ +

Using PeerTube

+ +

To set a password for your admin user, run:

+ +
cd /var/www/peertube/peertube-latest && NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run reset-password -- -u root
+ +

Login to your PeerTube instance using the admin email specified in your production.yaml file and the admin password you just set.

+ + + +

Once logged in, it's recommended to create a separate user without admin privileges for uploading videos to PeerTube. + This can be done easily from the users tab in the administration section:

+ +

Enjoy your PeerTube instance!

+ +
+

Written by Denshi. Donate Monero here [QR]

+ +
+ + + -- cgit v1.2.3