aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-23 09:00:23 +0100
committerChocobozzz <me@florianbigard.com>2018-01-23 09:00:23 +0100
commit59c48d49c5f06a46c342b4e7f86fbd1ed9894bd6 (patch)
tree84bae36b9953b0369946a686faac1ed6cb5f82da
parente5203ffa1260ee03f0f84ef6b65d57ccad5ee695 (diff)
downloadPeerTube-59c48d49c5f06a46c342b4e7f86fbd1ed9894bd6.tar.gz
PeerTube-59c48d49c5f06a46c342b4e7f86fbd1ed9894bd6.tar.zst
PeerTube-59c48d49c5f06a46c342b4e7f86fbd1ed9894bd6.zip
Peertube home in /var/www instead of /home
-rw-r--r--config/production.yaml.example14
-rw-r--r--server/middlewares/oauth.ts1
-rw-r--r--support/doc/production.md43
-rw-r--r--support/nginx/peertube6
-rw-r--r--support/systemd/peertube.service4
5 files changed, 35 insertions, 33 deletions
diff --git a/config/production.yaml.example b/config/production.yaml.example
index 69052fb26..1288eeaa2 100644
--- a/config/production.yaml.example
+++ b/config/production.yaml.example
@@ -17,13 +17,13 @@ database:
17 17
18# From the project root directory 18# From the project root directory
19storage: 19storage:
20 avatars: '/home/peertube/storage/avatars/' 20 avatars: '/var/www/peertube/storage/avatars/'
21 videos: '/home/peertube/storage/videos/' 21 videos: '/var/www/peertube/storage/videos/'
22 logs: '/home/peertube/storage/logs/' 22 logs: '/var/www/peertube/storage/logs/'
23 previews: '/home/peertube/storage/previews/' 23 previews: '/var/www/peertube/storage/previews/'
24 thumbnails: '/home/peertube/storage/thumbnails/' 24 thumbnails: '/var/www/peertube/storage/thumbnails/'
25 torrents: '/home/peertube/storage/torrents/' 25 torrents: '/var/www/peertube/storage/torrents/'
26 cache: '/home/peertube/storage/cache/' 26 cache: '/var/www/peertube/storage/cache/'
27 27
28log: 28log:
29 level: 'debug' # debug/info/warning/error 29 level: 'debug' # debug/info/warning/error
diff --git a/server/middlewares/oauth.ts b/server/middlewares/oauth.ts
index 3cda41e5c..41a3fb718 100644
--- a/server/middlewares/oauth.ts
+++ b/server/middlewares/oauth.ts
@@ -1,7 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import * as OAuthServer from 'express-oauth-server' 2import * as OAuthServer from 'express-oauth-server'
3import 'express-validator' 3import 'express-validator'
4import { logger } from '../helpers/logger'
5import { OAUTH_LIFETIME } from '../initializers' 4import { OAUTH_LIFETIME } from '../initializers'
6 5
7const oAuthServer = new OAuthServer({ 6const oAuthServer = new OAuthServer({
diff --git a/support/doc/production.md b/support/doc/production.md
index ee8bf2647..606f13c9b 100644
--- a/support/doc/production.md
+++ b/support/doc/production.md
@@ -8,10 +8,10 @@ Follow the steps of the [dependencies guide](dependencies.md).
8 8
9### PeerTube user 9### PeerTube user
10 10
11Create a `peertube` user with `/home/peertube` home: 11Create a `peertube` user with `/var/www/peertube` home:
12 12
13``` 13```
14$ sudo useradd -m -d /home/peertube -s /bin/bash -p peertube peertube 14$ sudo useradd -m -d /var/www/peertube -s /bin/bash -p peertube peertube
15``` 15```
16 16
17Set its password: 17Set its password:
@@ -34,19 +34,22 @@ Fetch the latest tagged version of Peertube
34``` 34```
35$ 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" 35$ 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"
36``` 36```
37
37Open the peertube directory, create a few required directories 38Open the peertube directory, create a few required directories
38``` 39```
39 cd /home/peertube && sudo -u peertube mkdir config storage versions && cd versions 40cd /var/www/peertube && sudo -u peertube mkdir config storage versions && cd versions
40``` 41```
42
41Download the latest version of the Peertube client, unzip it and remove the zip 43Download the latest version of the Peertube client, unzip it and remove the zip
42``` 44```
43 sudo -u peertube wget -q "https://github.com/Chocobozzz/PeerTube/releases/download/${VERSION}/peertube-${VERSION}.zip" && \ 45sudo -u peertube wget -q "https://github.com/Chocobozzz/PeerTube/releases/download/${VERSION}/peertube-${VERSION}.zip" && \
44 sudo -u peertube unzip peertube-${VERSION}.zip && sudo -u peertube rm peertube-${VERSION}.zip 46sudo -u peertube unzip peertube-${VERSION}.zip && sudo -u peertube rm peertube-${VERSION}.zip
45``` 47```
48
46Install Peertube 49Install Peertube
47``` 50```
48 cd ../ && sudo -u peertube ln -s versions/peertube-${VERSION} ./peertube-latest && \ 51cd ../ && sudo -u peertube ln -s versions/peertube-${VERSION} ./peertube-latest && \
49 cd ./peertube-latest && sudo -u peertube yarn install --production --pure-lockfile 52cd ./peertube-latest && sudo -u peertube yarn install --production --pure-lockfile
50``` 53```
51 54
52### PeerTube configuration 55### PeerTube configuration
@@ -54,7 +57,7 @@ Install Peertube
54Copy example configuration: 57Copy example configuration:
55 58
56``` 59```
57$ cd /home/peertube && sudo -u peertube cp peertube-latest/config/production.yaml.example config/production.yaml 60$ cd /var/www/peertube && sudo -u peertube cp peertube-latest/config/production.yaml.example config/production.yaml
58``` 61```
59 62
60Then edit the `config/production.yaml` file according to your webserver 63Then edit the `config/production.yaml` file according to your webserver
@@ -65,7 +68,7 @@ configuration.
65Copy the nginx configuration template: 68Copy the nginx configuration template:
66 69
67``` 70```
68$ sudo cp /home/peertube/peertube-latest/support/nginx/peertube /etc/nginx/sites-available/peertube 71$ sudo cp /var/www/peertube/peertube-latest/support/nginx/peertube /etc/nginx/sites-available/peertube
69``` 72```
70 73
71Then modify the webserver configuration file. Please pay attention to the `alias` keys of the static locations. 74Then modify the webserver configuration file. Please pay attention to the `alias` keys of the static locations.
@@ -112,13 +115,13 @@ server {
112 location ~ ^/client/(.*\.(js|css|woff2|otf|ttf|woff|eot))$ { 115 location ~ ^/client/(.*\.(js|css|woff2|otf|ttf|woff|eot))$ {
113 add_header Cache-Control "public, max-age=31536000, immutable"; 116 add_header Cache-Control "public, max-age=31536000, immutable";
114 117
115 alias /home/peertube/peertube-latest/client/dist/$1; 118 alias /var/www/peertube/peertube-latest/client/dist/$1;
116 } 119 }
117 120
118 location ~ ^/static/(thumbnails|avatars)/(.*)$ { 121 location ~ ^/static/(thumbnails|avatars)/(.*)$ {
119 add_header Cache-Control "public, max-age=31536000, immutable"; 122 add_header Cache-Control "public, max-age=31536000, immutable";
120 123
121 alias /home/peertube/storage/$1/$2; 124 alias /var/www/peertube/storage/$1/$2;
122 } 125 }
123 126
124 location / { 127 location / {
@@ -156,7 +159,7 @@ server {
156 access_log off; 159 access_log off;
157 } 160 }
158 161
159 alias /home/peertube/storage/videos; 162 alias /var/www/peertube/storage/videos;
160 } 163 }
161 164
162 # Websocket tracker 165 # Websocket tracker
@@ -187,7 +190,7 @@ $ sudo systemctl reload nginx
187Copy the nginx configuration template: 190Copy the nginx configuration template:
188 191
189``` 192```
190$ sudo cp /home/peertube/peertube-latest/support/systemd/peertube.service /etc/systemd/system/ 193$ sudo cp /var/www/peertube/peertube-latest/support/systemd/peertube.service /etc/systemd/system/
191``` 194```
192 195
193Update the service file: 196Update the service file:
@@ -206,11 +209,11 @@ After=network.target
206[Service] 209[Service]
207Type=simple 210Type=simple
208Environment=NODE_ENV=production 211Environment=NODE_ENV=production
209Environment=NODE_CONFIG_DIR=/home/peertube/config 212Environment=NODE_CONFIG_DIR=/var/www/peertube/config
210User=peertube 213User=peertube
211Group=peertube 214Group=peertube
212ExecStart=/usr/bin/npm start 215ExecStart=/usr/bin/npm start
213WorkingDirectory=/home/peertube/peertube-latest 216WorkingDirectory=/var/www/peertube/peertube-latest
214StandardOutput=syslog 217StandardOutput=syslog
215StandardError=syslog 218StandardError=syslog
216SyslogIdentifier=peertube 219SyslogIdentifier=peertube
@@ -246,7 +249,7 @@ The administrator password is automatically generated and can be found in the
246logs. You can set another password with: 249logs. You can set another password with:
247 250
248``` 251```
249$ cd /home/peertube/peertube-latest && NODE_CONFIG_DIR=/home/peertube/config NODE_ENV=production npm run reset-password -- -u root 252$ cd /var/www/peertube/peertube-latest && NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run reset-password -- -u root
250``` 253```
251 254
252## Upgrade 255## Upgrade
@@ -255,21 +258,21 @@ Make a SQL backup:
255 258
256``` 259```
257$ SQL_BACKUP_PATH="backup/sql-peertube_prod-$(date -Im).bak" && \ 260$ SQL_BACKUP_PATH="backup/sql-peertube_prod-$(date -Im).bak" && \
258 cd /home/peertube && sudo -u peertube mkdir -p backup && \ 261 cd /var/www/peertube && sudo -u peertube mkdir -p backup && \
259 sudo pg_dump -U peertube -W -h localhost -F c peertube_prod -f "$SQL_BACKUP_PATH" 262 sudo pg_dump -U peertube -W -h localhost -F c peertube_prod -f "$SQL_BACKUP_PATH"
260``` 263```
261 264
262Update your configuration file. **If some keys are missing, your upgraded PeerTube won't start!** 265Update your configuration file. **If some keys are missing, your upgraded PeerTube won't start!**
263 266
264``` 267```
265$ diff <(curl -s https://raw.githubusercontent.com/Chocobozzz/PeerTube/develop/config/production.yaml.example) /home/peertube/config/production.yaml 268$ diff <(curl -s https://raw.githubusercontent.com/Chocobozzz/PeerTube/develop/config/production.yaml.example) /var/www/peertube/config/production.yaml
266``` 269```
267 270
268Upgrade PeerTube: 271Upgrade PeerTube:
269 272
270``` 273```
271$ VERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4) && \ 274$ VERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4) && \
272 cd /home/peertube/versions && \ 275 cd /var/www/peertube/versions && \
273 sudo -u peertube wget -q "https://github.com/Chocobozzz/PeerTube/releases/download/${VERSION}/peertube-${VERSION}.zip" && \ 276 sudo -u peertube wget -q "https://github.com/Chocobozzz/PeerTube/releases/download/${VERSION}/peertube-${VERSION}.zip" && \
274 sudo -u peertube unzip -o peertube-${VERSION}.zip && sudo -u peertube rm peertube-${VERSION}.zip && \ 277 sudo -u peertube unzip -o peertube-${VERSION}.zip && sudo -u peertube rm peertube-${VERSION}.zip && \
275 cd ../ && sudo rm ./peertube-latest && sudo -u peertube ln -s versions/peertube-${VERSION} ./peertube-latest && \ 278 cd ../ && sudo rm ./peertube-latest && sudo -u peertube ln -s versions/peertube-${VERSION} ./peertube-latest && \
@@ -281,7 +284,7 @@ Things went wrong? Change `peertube-latest` destination to the previous version
281 284
282``` 285```
283$ OLD_VERSION="v0.42.42" && SQL_BACKUP_PATH="backup/sql-peertube_prod-2018-01-19T10:18+01:00.bak" && \ 286$ OLD_VERSION="v0.42.42" && SQL_BACKUP_PATH="backup/sql-peertube_prod-2018-01-19T10:18+01:00.bak" && \
284 cd /home/peertube && rm ./peertube-latest && \ 287 cd /var/www/peertube && rm ./peertube-latest && \
285 sudo -u peertube ln -s "versions/peertube-$OLD_VERSION" peertube-latest && \ 288 sudo -u peertube ln -s "versions/peertube-$OLD_VERSION" peertube-latest && \
286 pg_restore -U peertube -c -d peertube_prod "$SQL_BACKUP_PATH" 289 pg_restore -U peertube -c -d peertube_prod "$SQL_BACKUP_PATH"
287 sudo systemctl restart peertube 290 sudo systemctl restart peertube
diff --git a/support/nginx/peertube b/support/nginx/peertube
index 098818e57..5261cddb4 100644
--- a/support/nginx/peertube
+++ b/support/nginx/peertube
@@ -26,13 +26,13 @@ server {
26 location ~ ^/client/(.*\.(js|css|woff2|otf|ttf|woff|eot))$ { 26 location ~ ^/client/(.*\.(js|css|woff2|otf|ttf|woff|eot))$ {
27 add_header Cache-Control "public, max-age=31536000, immutable"; 27 add_header Cache-Control "public, max-age=31536000, immutable";
28 28
29 alias /home/peertube/peertube-latest/client/dist/$1; 29 alias /var/www/peertube/peertube-latest/client/dist/$1;
30 } 30 }
31 31
32 location ~ ^/static/(thumbnails|avatars)/(.*)$ { 32 location ~ ^/static/(thumbnails|avatars)/(.*)$ {
33 add_header Cache-Control "public, max-age=31536000, immutable"; 33 add_header Cache-Control "public, max-age=31536000, immutable";
34 34
35 alias /home/peertube/storage/$1/$2; 35 alias /var/www/peertube/storage/$1/$2;
36 } 36 }
37 37
38 location / { 38 location / {
@@ -72,7 +72,7 @@ server {
72 access_log off; 72 access_log off;
73 } 73 }
74 74
75 alias /home/peertube/storage/videos; 75 alias /var/www/peertube/storage/videos;
76 } 76 }
77 77
78 # Websocket tracker 78 # Websocket tracker
diff --git a/support/systemd/peertube.service b/support/systemd/peertube.service
index 03ead9fbd..047ce7e56 100644
--- a/support/systemd/peertube.service
+++ b/support/systemd/peertube.service
@@ -5,11 +5,11 @@ After=network.target
5[Service] 5[Service]
6Type=simple 6Type=simple
7Environment=NODE_ENV=production 7Environment=NODE_ENV=production
8Environment=NODE_CONFIG_DIR=/home/peertube/config 8Environment=NODE_CONFIG_DIR=/var/www/peertube/config
9User=peertube 9User=peertube
10Group=peertube 10Group=peertube
11ExecStart=/usr/bin/npm start 11ExecStart=/usr/bin/npm start
12WorkingDirectory=/home/peertube/peertube-latest 12WorkingDirectory=/var/www/peertube/peertube-latest
13StandardOutput=syslog 13StandardOutput=syslog
14StandardError=syslog 14StandardError=syslog
15SyslogIdentifier=peertube 15SyslogIdentifier=peertube