3 * [Installation](#installation)
8 **Please don't install PeerTube for production on a small device behind a low bandwidth connection (example: a Raspberry PI behind your ADSL link) because it could slow down the fediverse.**
12 Follow the steps of the [dependencies guide](dependencies.md).
16 Create a `peertube` user with `/var/www/peertube` home:
19 $ sudo useradd -m -d /var/www/peertube -s /bin/bash -p peertube peertube
24 $ sudo passwd peertube
29 Create the production database and a peertube user inside PostgreSQL:
32 $ sudo -u postgres createuser -P peertube
33 $ sudo -u postgres createdb -O peertube peertube_prod
36 ### Prepare PeerTube directory
38 Fetch the latest tagged version of Peertube
40 $ 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"
43 Open the peertube directory, create a few required directories
45 $ cd /var/www/peertube && sudo -u peertube mkdir config storage versions && cd versions
48 Download the latest version of the Peertube client, unzip it and remove the zip
50 $ sudo -u peertube wget -q "https://github.com/Chocobozzz/PeerTube/releases/download/${VERSION}/peertube-${VERSION}.zip"
51 $ sudo -u peertube unzip peertube-${VERSION}.zip && sudo -u peertube rm peertube-${VERSION}.zip
56 $ cd ../ && sudo -u peertube ln -s versions/peertube-${VERSION} ./peertube-latest
57 $ cd ./peertube-latest && sudo -H -u peertube yarn install --production --pure-lockfile
60 ### PeerTube configuration
62 Copy example configuration:
65 $ cd /var/www/peertube && sudo -u peertube cp peertube-latest/config/production.yaml.example config/production.yaml
68 Then edit the `config/production.yaml` file according to your webserver
71 **PeerTube does not support webserver host change**. Keep in mind your domain name is definitive after your first PeerTube start.
75 We only provide official configuration files for Nginx.
77 Copy the nginx configuration template:
80 $ sudo cp /var/www/peertube/peertube-latest/support/nginx/peertube /etc/nginx/sites-available/peertube
83 Then modify the webserver configuration file. Please pay attention to the `alias` keys of the static locations.
84 It should correspond to the paths of your storage directories (set in the configuration file inside the `storage` key).
87 $ sudo vim /etc/nginx/sites-available/peertube
90 Activate the configuration file:
93 $ sudo ln -s /etc/nginx/sites-available/peertube /etc/nginx/sites-enabled/peertube
96 To generate the certificate for your domain as required to make https work you can use [Let's Encrypt](https://letsencrypt.org/):
99 $ sudo systemctl stop nginx
100 $ sudo vim /etc/nginx/sites-available/peertube # Comment ssl_certificate and ssl_certificate_key lines
101 $ sudo certbot --authenticator standalone --installer nginx --post-hook "systemctl start nginx"
102 $ sudo vim /etc/nginx/sites-available/peertube # Uncomment ssl_certificate and ssl_certificate_key lines
103 $ sudo systemctl reload nginx
106 Remember your certificate will expire in 90 days, and thus needs renewal.
108 Now you have the certificates you can reload nginx:
111 $ sudo systemctl reload nginx
116 If your OS uses systemd, copy the configuration template:
119 $ sudo cp /var/www/peertube/peertube-latest/support/systemd/peertube.service /etc/systemd/system/
122 Update the service file:
125 $ sudo vim /etc/systemd/system/peertube.service
129 Tell systemd to reload its config:
132 $ sudo systemctl daemon-reload
135 If you want to start PeerTube on boot:
138 $ sudo systemctl enable peertube
144 $ sudo systemctl start peertube
145 $ sudo journalctl -feu peertube
150 If you're using FreeBSD, copy the startup script and update rc.conf:
153 $ sudo cp /var/www/peertube/peertube-latest/support/freebsd/peertube /usr/local/etc/rc.d/
154 $ sudo chmod +x /usr/local/etc/rc.d/peertube
155 $ sudo echo peertube_enable="YES" >> /etc/rc.conf
161 $ sudo service peertube start
166 The administrator password is automatically generated and can be found in the
167 logs. You can set another password with:
170 $ cd /var/www/peertube/peertube-latest && NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run reset-password -- -u root
173 Now you can subscribe to the mailing list for PeerTube administrators: https://framalistes.org/sympa/subscribe/peertube-admin
177 #### Auto (minor versions only)
180 $ cd /var/www/peertube/peertube-latest/scripts && sudo -u peertube ./upgrade.sh
181 $ sudo systemctl restart peertube && sudo journalctl -fu peertube
189 $ SQL_BACKUP_PATH="backup/sql-peertube_prod-$(date -Im).bak" && \
190 cd /var/www/peertube && sudo -u peertube mkdir -p backup && \
191 sudo pg_dump -U peertube -W -h localhost -F c peertube_prod -f "$SQL_BACKUP_PATH"
194 Fetch the latest tagged version of Peertube:
197 $ 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"
200 Download the new version and unzip it:
203 $ cd /var/www/peertube/versions && \
204 sudo -u peertube wget -q "https://github.com/Chocobozzz/PeerTube/releases/download/${VERSION}/peertube-${VERSION}.zip" && \
205 sudo -u peertube unzip -o peertube-${VERSION}.zip && \
206 sudo -u peertube rm peertube-${VERSION}.zip
209 Install node dependencies:
212 $ cd /var/www/peertube/versions/peertube-${VERSION} && \
213 sudo -u peertube yarn install --production --pure-lockfile
216 Copy new configuration defaults values and update your configuration file:
219 $ sudo -u peertube cp /var/www/peertube/versions/peertube-${VERSION}/config/default.yaml /var/www/peertube/config/default.yaml
220 $ diff /var/www/peertube/versions/peertube-${VERSION}/config/production.yaml.example /var/www/peertube/config/production.yaml
223 Change the link to point to the latest version:
226 $ cd /var/www/peertube && \
227 sudo unlink ./peertube-latest && \
228 sudo -u peertube ln -s versions/peertube-${VERSION} ./peertube-latest
234 $ sudo systemctl restart peertube
237 ### Things went wrong?
239 Change `peertube-latest` destination to the previous version and restore your SQL backup:
242 $ OLD_VERSION="v0.42.42" && SQL_BACKUP_PATH="backup/sql-peertube_prod-2018-01-19T10:18+01:00.bak" && \
243 cd /var/www/peertube && unlink ./peertube-latest && \
244 sudo -u peertube ln -s "versions/peertube-$OLD_VERSION" peertube-latest && \
245 pg_restore -U peertube -W -h localhost -c -d peertube_prod "$SQL_BACKUP_PATH"
246 sudo systemctl restart peertube