
This article provides an in-depth guide demonstrating how to install PeerTube on Ubuntu VPS.
What is PeerTube?
PeerTube is a decentralized, federated video hosting platform powered by WebTorrent and ActivityPub. It enables users to self-host video services and interact with other PeerTube instances.
PeerTube serves as an alternative to centralized platforms like YouTube, Vimeo, or Dailymotion. It is designed to give users control over their content without relying on a single corporation or central authority.
Key Features of PeerTube:
- Decentralized and Federated
- PeerTube operates on a federation model using the ActivityPub protocol, meaning multiple instances (servers) can host videos while still being connected to a larger network.
- Users can watch videos from different PeerTube instances without needing multiple accounts.
- Peer-to-Peer Streaming
- Uses WebTorrent technology to reduce server load by allowing viewers to share bandwidth while watching videos.
- This means the more people watch a video, the smoother it streams, reducing reliance on expensive hosting.
- No Ads & No Tracking
- Unlike YouTube, PeerTube does not monetize content through ads or track users for targeted advertising.
- Users have full control over their data and privacy.
- Self-Hosting & Customization
- Anyone can host their own PeerTube instance and set rules, moderation policies, and community guidelines.
- Supports customization, allowing admins to create unique video-sharing experiences.
- Free & Open-Source
- Developed by the French non-profit Framasoft, PeerTube is completely open-source, meaning anyone can modify, improve, or contribute to its development.
- Supports Live Streaming
- PeerTube now includes live streaming capabilities with peer-to-peer support, making it a viable option for independent creators.
We will walk you through the complete guide for how to install PeerTube on Ubuntu VPS.
Prerequisites
Before we discuss how to install PeerTube on Ubuntu VPS, ensure you have the following:
-
System Requirements
- A Ubuntu VPS (20.04 or 22.04 recommended)
- At least 2 CPU cores, 4 GB RAM, and 40 GB of storage (or more depending on your expected traffic and video storage needs)
- A domain name (e.g.,
yourdomain.com
) with proper DNS records (Register a Domain) - A non-root user with sudo privileges
-
Server Preparation
Ensure your system is up to date:
sudo apt update && sudo apt upgrade -y
Install necessary dependencies:
sudo apt install -y curl wget gnupg2 unzip ffmpeg
How to Install PeerTube on Ubuntu VPS
To Install PeerTube on Ubuntu VPS, follow the steps provided:
-
-
Set Up a PostgreSQL Database
PeerTube requires PostgreSQL as its database. Install it along with the required extensions:
sudo apt install -y postgresql postgresql-contrib
Switch to the PostgreSQL user:
sudo -i -u postgres
Create the PeerTube database and user:
CREATE DATABASE peertube; CREATE USER peertube WITH ENCRYPTED PASSWORD 'your_secure_password'; GRANT ALL PRIVILEGES ON DATABASE peertube TO peertube; \q
Exit PostgreSQL.
-
Install Redis
Redis is used for caching:
sudo apt install -y redis-server sudo systemctl enable redis sudo systemctl start redis
-
Install Node.js
PeerTube requires a specific version of Node.js. Install it using the Node Version Manager (nvm):
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash source ~/.bashrc nvm install 18 nvm use 18
Verify the installation:
node -v
It should output v18.x.x.
-
Install Yarn
Yarn is needed for managing PeerTube dependencies:
npm install -g yarn
-
Download and Configure PeerTube
Create a dedicated user for PeerTube:
sudo adduser --disabled-login --gecos "" peertube
Switch to the PeerTube user:
sudo su - peertube
Clone the latest stable PeerTube release:
git clone -b v6.0.0 https://github.com/Chocobozzz/PeerTube.git peertube cd peertube
Copy the sample configuration:
cp config/production.yaml.example config/production.yaml
Edit the configuration:
nano config/production.yaml
Modify the following fields:
webserver.hostname
: Set this to your domain (yourdomain.com
).database
: Update credentials to match your PostgreSQL user.redis
: Ensure Redis settings are correct.
Save the file (
CTRL+X
, thenY
andEnter
). -
Install PeerTube Dependencies
yarn install --production --pure-lockfile
Build the PeerTube client:
NODE_ENV=production yarn build
Run database migrations:
NODE_CONFIG_DIR=./config NODE_ENV=production npm run setup
-
Set Up Systemd Service
Exit the PeerTube user session and create a systemd service:
sudo nano /etc/systemd/system/peertube.service
Paste the following configuration:
[Unit] Description=PeerTube After=postgresql.service redis.service [Service] Type=simple User=peertube WorkingDirectory=/home/peertube/peertube ExecStart=/usr/bin/node ./dist/server Restart=always RestartSec=10 StandardOutput=syslog StandardError=syslog SyslogIdentifier=peertube [Install] WantedBy=multi-user.target
Save and exit.
Reload systemd:
sudo systemctl daemon-reload sudo systemctl enable peertube sudo systemctl start peertube
Check the status:
sudo systemctl status peertube
If running correctly, you should see “active (running)”.
-
Install and Configure Nginx
Install Nginx:
sudo apt install -y nginx
Create a new configuration file for PeerTube:
sudo nano /etc/nginx/sites-available/peertube
Paste the following:
server { listen 80; server_name yourdomain.com; location / { proxy_pass http://127.0.0.1:9000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
Save and exit.
Enable the configuration:
sudo ln -s /etc/nginx/sites-available/peertube /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl restart nginx
-
Secure with Let’s Encrypt SSL
Install Certbot:
sudo apt install -y certbot python3-certbot-nginx
Obtain an SSL certificate:
sudo certbot --nginx -d yourdomain.com
Follow the prompts to complete the installation. To auto-renew SSL, set up a cron job:
sudo crontab -e
Add this line at the bottom:
0 3 * * * certbot renew --quiet
This will renew SSL automatically.
-
Finalize Installation
Restart PeerTube and Nginx:
sudo systemctl restart peertube sudo systemctl restart nginx
Access PeerTube via
https://yourdomain.com
.Create an admin account:
sudo -u peertube NODE_CONFIG_DIR=/home/peertube/peertube/config NODE_ENV=production npm run reset-password -- -u root
Set your desired password.
-
Conclusion
You now know how to install PeerTube on Ubuntu VPS!
Now that you have successfully installed PeerTube on your Ubuntu VPS, you can customize your instance, add storage, and configure federation settings.🚀
[…] Federation: Users can follow and interact with accounts from other federated services like Mastodon, Pleroma, and PeerTube. […]