Updated 2 February 2021


PeerTube is a distributed video hosting and broadcasting platform. [PeerTube] ( is an independent, lightweight, scalable alternative to YouTube, Dailymotion and Vimeo. It uses visitor browsers to create a P2P-based distributed network. PeerTube supports the ActivityPub protocol, which allows you to merge isolated servers with video content into a federated network. People visiting it can subscribe to channels and be notified about new videos. This open source application is distributed under the AGPLv3 license.

Preparing a LXC container

We recommend that you install PeerTub in a separate container and configure it according to the manual.

Installing and configuring PostgreSQL

Install and configure PostgreSQL according to the manual. Replace dbtest with your peertube_prod database, and the test user with peertube. Complete the setup process:

psql -U postgres

psql (11.2)
Type "help" for help.
postgres=# \c peertube_prod
postgres=# CREATE EXTENSION pg_trgm;
postgres=# CREATE EXTENSION unaccent;
postgres=# \q

Installing PeerTube

Install the packages required by PeerTube:

emerge -a app-arch/unzip dev-db/redis media-video/ffmpeg dev-python/nodeenv

Create a peertube user account and protect it with a password:

mkdir -p /var/calculate/www

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

passwd peertube

Install Node.js in the user directory:

su - peertube

nodeenv --node=12.18.0 .node-12

ln -sfT .node-12 .node-live

source .node-live/bin/activate

npm install -g yarn

echo 'source ~/.node-live/bin/activate' >> ~/.bash_profile

Create the necessary paths, download and extract the latest version of PeerTube:

mkdir config storage versions

VERSION=$(curl -s | grep tag_name | cut -d '"' -f 4) && echo "Latest PeerTube version is $VERSION"

wget "${VERSION}/peertube-${VERSION}.zip" -P versions

unzip versions/peertube-${VERSION}.zip -d versions

rm versions/peertube-${VERSION}.zip

Install PeerTube:

ln -s versions/peertube-${VERSION} ./peertube-latest

cd ./peertube-latest

yarn install --production --pure-lockfile

cp /var/calculate/www/peertube/peertube-latest/config/default.yaml /var/calculate/www/peertube/config/default.yaml

cp config/production.yaml.example ../../config/production.yaml

PeerTube configuration

Setup PeerTube, replacing with your site:

# Correspond to your reverse proxy server_name/listen configuration
  https: true
  hostname: ''
  port: 443
# Your database name will be "peertube"+database.suffix
  hostname: 'localhost'
  port: 5432
  suffix: '_prod'
  username: 'peertube'
  password: 'secret'
    max: 5
# SMTP server to send emails
  port: 465 # If you use StartTLS: 587
  username: null
  password: null
  tls: false # If you use StartTLS: false
  disable_starttls: false
  ca_file: null # Used for self signed certificates
  from_address: ''
# From the project root directory
  tmp: '/var/calculate/www/peertube/storage/tmp/' # Used to download data (imports etc), store uploaded files before processing...
  avatars: '/var/calculate/www/peertube/storage/avatars/'
  videos: '/var/calculate/www/peertube/storage/videos/'
  streaming_playlists: '/var/calculate/www/peertube/storage/streaming-playlists/'
  redundancy: '/var/calculate/www/peertube/storage/videos/'
  logs: '/var/calculate/www/peertube/storage/logs/'
  previews: '/var/calculate/www/peertube/storage/previews/'
  thumbnails: '/var/calculate/www/peertube/storage/thumbnails/'
  torrents: '/var/calculate/www/peertube/storage/torrents/'
  captions: '/var/calculate/www/peertube/storage/captions/'
  cache: '/var/calculate/www/peertube/storage/cache/'
  plugins: '/var/calculate/www/peertube/storage/plugins/'
  client_overrides: '/var/calculate/www/peertube/storage/client-overrides/'
  # Used to generate the root user at first startup
  # And to receive emails from the contact form
  email: ''

Getting Let's Encrypt certificate

Get a certificate for Nginx on according to the manual.

Installing and configuring Nginx

Install and configure your Nginx server as a reverse proxy according to the manual.

Copy the default Nginx configuration file for PeerTube:

cp /var/calculate/www/peertube/peertube-latest/support/nginx/peertube /etc/nginx/sites-enabled/peertube.conf

Specify the paths and the server name,

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    ssl_certificate /etc/letsencrypt/live/;
    ssl_certificate_key /etc/letsencrypt/live/;
    # Bypass PeerTube for performance reasons. Could be removed
    location ~ ^/client/(.*\.(js|css|woff2|otf|ttf|woff|eot))$ {
        add_header Cache-Control "public, max-age=31536000, immutable";
        alias /var/calculate/www/peertube/peertube-latest/client/dist/$1;
    # Cache 2 hours
    add_header Cache-Control "public, max-age=7200";
    root /var/calculate/www/peertube/storage;
    rewrite ^/static/(thumbnails|avatars)/(.*)$ /$1/$2 break;
    try_files $uri
        # Don't spam access log file with byte range requests
        access_log off;
    root /var/calculate/www/peertube/storage;
    rewrite ^/static/webseed/(.*)$ /videos/$1 break;
    rewrite ^/static/redundancy/(.*)$ /redundancy/$1 break;

Starting PeerTube

Create an OpenRC script for PeerTube:

# Copyright 2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

name="PeerTube daemon"
start_stop_daemon_args="-e NODE_ENV=production -e NODE_CONFIG_DIR=/var/calculate/www/peertube/config -e PATH=/var/calculate/www/peertube/.node-live/lib/node_modules/.bin:/var/calculate/www/peertube/.node-live/bin:\"$PATH\""

depend() {
        need nginx postgresql redis

start_pre() {
    checkpath -f -o peertube -m 0600 /var/log/peertube.log

Define the privileges:

chmod 0755 /etc/init.d/peertube

Launch the PeerTube daemon:

/etc/init.d/peertube start

Add PeerTube to autostart:

rc-update add peertube

Open in your Web browser:

Defining the administration password

The administrator password is created automatically. You can find it in the log. To reset the password, run:

su - peertube

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


Updating PeerTube

Node.js update

When updating Peertube to 3.0.1, make sure that your Node.js is not earlier than 12:

su - peertube

node -v

Node.js update

If it is earlier than 12, install version 12.18.0 in the new .node-12 environment and make it the current one:


nodeenv --node=12.18.0 .node-12

ln -sfT .node-12 .node-live

source .node-live/bin/activate

npm install -g yarn

If you used the previous version of the manual to configure your Peertube, replace .node-10 with .node-live in /var/calculate/www/peertube/.bash_profile and /etc/init.d/peertube.

Source code update

Download and unpack the new version of PeerTube:

su - peertube

VERSION=$(curl -s | grep tag_name | cut -d '"' -f 4) && echo "Latest PeerTube version is $VERSION"

wget "${VERSION}/peertube-${VERSION}.zip" -P versions

unzip versions/peertube-${VERSION}.zip -d versions

rm versions/peertube-${VERSION}.zip

Install PeerTube:

cd versions/peertube-${VERSION}

yarn install --production --pure-lockfile

Configuration update

Copy the new default configuration file:

cp config/default.yaml /var/calculate/www/peertube/config/default.yaml

Update your production.yml configuration:

mv /var/calculate/www/peertube/config/production.yaml /var/calculate/www/peertube/config/production-old.yaml

cp config/production.yaml.example /var/calculate/www/peertube/config/production.yaml

Check the differences and move your settings to production.yaml:

git diff /var/calculate/www/peertube/config/production{,-old}.yaml

Choosing current version

Update the symlink:


unlink peertube-latest

ln -s versions/peertube-${VERSION} ./peertube-latest


Now restart PeerTube:

/etc/init.d/peertube restart

Moving to version 2.1.0

To update to version 2.1.0, run the HLS video torrents creation script:

su - peertube

cd /var/calculate/www/peertube/peertube-latest

NODE_CONFIG_DIR=/var/calculate/www/peertube/config NODE_ENV=production node dist/scripts/migrations/peertube-2.1.js


Moving to version 2.2.0

Connect to the database and make the following request:

psql -U postgres

psql (11.7)
Type "help" for help.

postgres=# \c peertube_prod 
You are now connected to database "peertube_prod" as user "postgres".
peertube_prod=# select "preferredUsername" from actor where "serverId" is null group by "preferredUsername" having count(*) > 1;
(0 rows)

If the result of the query is not empty, you need to change preferredUsername for each entry so that it be unique.