7 Follow the steps of the [dependencies guide](dependencies.md).
11 Create a `peertube` user with `/home/peertube` home:
14 sudo useradd -m -d /home/peertube -s /bin/bash -p peertube peertube
20 Create production database and peertube user:
23 sudo -u postgres createuser -P peertube
24 sudo -u postgres createdb -O peertube peertube_prod
29 Clone, install node dependencies and build application:
33 $ sudo -u peertube git clone -b master https://github.com/Chocobozzz/PeerTube
35 $ sudo -u peertube yarn install --pure-lockfile
36 $ sudo -u peertube npm run build
39 ### PeerTube configuration
41 Copy example configuration:
44 $ sudo -u peertube cp config/production.yaml.example config/production.yaml
47 Then edit the `config/production.yaml` file according to your webserver
48 configuration. Keys set in this file will override those of
53 Copy the nginx configuration template:
56 $ sudo cp /home/peertube/PeerTube/support/nginx/peertube-https /etc/nginx/sites-available/peertube
59 Then modify the webserver configuration file. Please pay attention to the `alias` key of `/static/webseed` location.
60 It should correspond to the path of your videos directory (set in the configuration file as `storage->videos` key).
63 $ sudo vim /etc/nginx/sites-available/peertube
66 If you want to set https with Let's Encrypt please follow the steps of [this guide](https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04).
68 An example of the nginx configuration could be:
74 server_name peertube.example.com;
76 access_log /var/log/nginx/peertube.example.com.access.log;
77 error_log /var/log/nginx/peertube.example.com.error.log;
79 rewrite ^ https://$server_name$request_uri? permanent;
84 listen [::]:443 ssl http2;
85 server_name peertube.example.com;
87 # For example with Let's Encrypt
88 ssl_certificate /etc/letsencrypt/live/peertube.example.com/fullchain.pem;
89 ssl_certificate_key /etc/letsencrypt/live/peertube.example.com/privkey.pem;
90 ssl_trusted_certificate /etc/letsencrypt/live/peertube.example.com/chain.pem;
92 access_log /var/log/nginx/peertube.example.com.access.log;
93 error_log /var/log/nginx/peertube.example.com.error.log;
95 location ^~ '/.well-known/acme-challenge' {
96 default_type "text/plain";
97 root /var/www/certbot;
101 proxy_pass http://localhost:9000;
102 proxy_set_header X-Real-IP $remote_addr;
103 proxy_set_header Host $host;
104 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
106 # For the video upload
107 client_max_body_size 8G;
108 proxy_connect_timeout 600;
109 proxy_send_timeout 600;
110 proxy_read_timeout 600;
114 # Bypass PeerTube webseed route for better performances
115 location /static/webseed {
116 if ($request_method = 'OPTIONS') {
117 add_header 'Access-Control-Allow-Origin' '*';
118 add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
119 add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
120 add_header 'Access-Control-Max-Age' 1728000;
121 add_header 'Content-Type' 'text/plain charset=UTF-8';
122 add_header 'Content-Length' 0;
126 if ($request_method = 'GET') {
127 add_header 'Access-Control-Allow-Origin' '*';
128 add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
129 add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
132 alias /var/www/PeerTube/videos;
136 location /tracker/socket {
137 # Peers send a message to the tracker every 15 minutes
138 # Don't close the websocket before this time
139 proxy_read_timeout 1200s;
140 proxy_set_header Upgrade $http_upgrade;
141 proxy_set_header Connection "upgrade";
142 proxy_http_version 1.1;
143 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
144 proxy_set_header Host $host;
145 proxy_pass http://localhost:9000;
151 Activate the configuration file:
154 $ sudo ln -s /etc/nginx/sites-available/peertube /etc/nginx/sites-enabled/peertube
155 $ sudo systemctl reload nginx
160 Copy the nginx configuration template:
163 sudo cp /home/peertube/PeerTube/support/systemd/peertube.service /etc/systemd/system/
166 Update the service file:
169 sudo vim /etc/systemd/system/peertube.service
172 It should look like this:
176 Description=PeerTube daemon
181 Environment=NODE_ENV=production
184 ExecStart=/usr/bin/npm start
185 WorkingDirectory=/home/peertube/PeerTube
186 StandardOutput=syslog
188 SyslogIdentifier=peertube
192 WantedBy=multi-user.target
196 Tell systemd to reload its config:
199 sudo systemctl daemon-reload
202 If you want to start PeerTube on boot:
205 sudo systemctl enabled peertube
211 sudo systemctl start peertube
212 sudo journalctl -feu peertube
217 The administrator password is automatically generated and can be found in the
218 logs. You can set another password with:
221 $ NODE_ENV=production npm run reset-password -- -u root
226 The following commands will upgrade the source (according to your current
227 branch), upgrade node modules and rebuild client application:
230 # systemctl stop peertube
231 $ npm run upgrade-peertube
232 # systemctl start peertube