diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-12 18:07:41 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-12 18:07:41 +0100 |
commit | 63bfad7ec984dad1e9a96de1f191db5cc78db5bf (patch) | |
tree | fe003158afa1ab6795652ae114c08be580078efb /support/doc | |
parent | 339632b4a3f94a6ebee3767054ef6c701858a785 (diff) | |
download | PeerTube-63bfad7ec984dad1e9a96de1f191db5cc78db5bf.tar.gz PeerTube-63bfad7ec984dad1e9a96de1f191db5cc78db5bf.tar.zst PeerTube-63bfad7ec984dad1e9a96de1f191db5cc78db5bf.zip |
Try to improve documentations/readme
Diffstat (limited to 'support/doc')
-rw-r--r-- | support/doc/dependencies.md | 29 | ||||
-rw-r--r-- | support/doc/development/client/code.md | 7 | ||||
-rw-r--r-- | support/doc/development/server/code.md | 15 | ||||
-rw-r--r-- | support/doc/production.md | 227 |
4 files changed, 257 insertions, 21 deletions
diff --git a/support/doc/dependencies.md b/support/doc/dependencies.md new file mode 100644 index 000000000..d77724b5a --- /dev/null +++ b/support/doc/dependencies.md | |||
@@ -0,0 +1,29 @@ | |||
1 | # Installation | ||
2 | |||
3 | ## Dependencies | ||
4 | |||
5 | ### Debian / Ubuntu | ||
6 | |||
7 | 1. Install NodeJS 8.x (current LTS): | ||
8 | [https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions](https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions) | ||
9 | 2. Install yarn: | ||
10 | [https://yarnpkg.com/en/docs/install](https://yarnpkg.com/en/docs/install) | ||
11 | 4. Run: | ||
12 | |||
13 | ```bash | ||
14 | $ apt-get update | ||
15 | $ apt-get install nginx ffmpeg postgresql openssl g++ make | ||
16 | ``` | ||
17 | |||
18 | ### Arch Linux | ||
19 | |||
20 | 1. Run: | ||
21 | |||
22 | ```bash | ||
23 | $ pacman -S nodejs yarn ffmpeg postgresql openssl | ||
24 | ``` | ||
25 | |||
26 | ### Other distributions | ||
27 | |||
28 | Feel free to update this file in a pull request! | ||
29 | |||
diff --git a/support/doc/development/client/code.md b/support/doc/development/client/code.md index ddd277e54..749783c29 100644 --- a/support/doc/development/client/code.md +++ b/support/doc/development/client/code.md | |||
@@ -53,12 +53,7 @@ Details of the Angular application file structure. It tries to follow [the offic | |||
53 | 53 | ||
54 | Uses [TSLint](https://palantir.github.io/tslint/) for TypeScript linting and [Angular styleguide](https://angular.io/docs/ts/latest/guide/style-guide.html). | 54 | Uses [TSLint](https://palantir.github.io/tslint/) for TypeScript linting and [Angular styleguide](https://angular.io/docs/ts/latest/guide/style-guide.html). |
55 | 55 | ||
56 | ## Developing | 56 | ## Concepts |
57 | |||
58 | * Install [the dependencies](https://github.com/Chocobozzz/PeerTube#dependencies) | ||
59 | * Run `yarn install --pure-lockfile` at the root directory to install all the dependencies | ||
60 | * Run PostgreSQL and create the database `peertube_dev`. | ||
61 | * Run `npm run dev:client` to compile the client, run the server, watch client files modifications and reload modules on the fly (you don't need to refresh manually the web browser). The API listen on `localhost:9000` and the client on `localhost:3000`. | ||
62 | 57 | ||
63 | In a Angular application, we create components that we put together. Each component is defined by an HTML structure, a TypeScript file and optionally a SASS file. | 58 | In a Angular application, we create components that we put together. Each component is defined by an HTML structure, a TypeScript file and optionally a SASS file. |
64 | If you are not familiar with Angular I recommend you to read the [quickstart guide](https://angular.io/docs/ts/latest/quickstart.html). | 59 | If you are not familiar with Angular I recommend you to read the [quickstart guide](https://angular.io/docs/ts/latest/quickstart.html). |
diff --git a/support/doc/development/server/code.md b/support/doc/development/server/code.md index d909b0c3d..ddb93119b 100644 --- a/support/doc/development/server/code.md +++ b/support/doc/development/server/code.md | |||
@@ -36,21 +36,6 @@ All other server files are in the [server](https://github.com/Chocobozzz/PeerTub | |||
36 | 36 | ||
37 | Uses [JavaScript Standard Style](http://standardjs.com/). | 37 | Uses [JavaScript Standard Style](http://standardjs.com/). |
38 | 38 | ||
39 | |||
40 | ## Developing | ||
41 | |||
42 | * Install [the dependencies](https://github.com/Chocobozzz/PeerTube#dependencies) | ||
43 | * Run `yarn install` at the root directory to install all the dependencies | ||
44 | * Run PostgreSQL and create the database `peertube_dev`. | ||
45 | * Run `npm run dev:server` to run the server, watch server files modifications and restart it automatically. The server (API + client) listen on `localhost:9000`. | ||
46 | |||
47 | The `NODE_ENV=test` is set to speed up communications between instances (see [constants.ts](https://github.com/Chocobozzz/PeerTube/blob/master/server/initializers/constants.ts)). | ||
48 | |||
49 | `npm run help` gives you all available commands. | ||
50 | |||
51 | If you want to test the decentralization feature, you can easily run 3 instances by running `npm run play`. The instances password are `test1`, `test2` and `test3`. | ||
52 | |||
53 | |||
54 | ## Architecture | 39 | ## Architecture |
55 | 40 | ||
56 | The server is composed by: | 41 | The server is composed by: |
diff --git a/support/doc/production.md b/support/doc/production.md new file mode 100644 index 000000000..4d7c14f2b --- /dev/null +++ b/support/doc/production.md | |||
@@ -0,0 +1,227 @@ | |||
1 | # Production guide | ||
2 | |||
3 | ## Installation | ||
4 | |||
5 | ### Dependencies | ||
6 | |||
7 | Follow the steps of the [dependencies guide](dependencies.md). | ||
8 | |||
9 | ### PeerTube user | ||
10 | |||
11 | Create a `peertube` user with `/home/peertube` home: | ||
12 | |||
13 | ```bash | ||
14 | sudo useradd -m -d /home/peertube -s /bin/bash -p peertube peertube | ||
15 | sudo passwd peertube | ||
16 | ``` | ||
17 | |||
18 | ### Database | ||
19 | |||
20 | Create production database and peertube user: | ||
21 | |||
22 | ```bash | ||
23 | sudo -u postgres createuser -P peertube | ||
24 | sudo -u postgres createdb -O peertube peertube_prod | ||
25 | ``` | ||
26 | |||
27 | ### Sources | ||
28 | |||
29 | Clone, install node dependencies and build application: | ||
30 | |||
31 | ```bash | ||
32 | $ cd /home/peertube | ||
33 | $ sudo -u peertube git clone -b master https://github.com/Chocobozzz/PeerTube | ||
34 | $ cd PeerTube | ||
35 | $ sudo -u peertube yarn install --pure-lockfile | ||
36 | $ sudo -u peertube npm run build | ||
37 | ``` | ||
38 | |||
39 | ### PeerTube configuration | ||
40 | |||
41 | Copy example configuration: | ||
42 | |||
43 | ```bash | ||
44 | $ sudo -u peertube cp config/production.yaml.example config/production.yaml | ||
45 | ``` | ||
46 | |||
47 | Then edit the `config/production.yaml` file according to your webserver | ||
48 | configuration. Keys set in this file will override those of | ||
49 | `config/default.yml`. | ||
50 | |||
51 | ### Webserver | ||
52 | |||
53 | Copy the nginx configuration template: | ||
54 | |||
55 | ```bash | ||
56 | $ sudo cp /home/peertube/PeerTube/support/nginx/peertube-https /etc/nginx/sites-available/peertube | ||
57 | ``` | ||
58 | |||
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). | ||
61 | |||
62 | ```bash | ||
63 | $ sudo vim /etc/nginx/sites-available/peertube | ||
64 | ``` | ||
65 | |||
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). | ||
67 | |||
68 | An example of the nginx configuration could be: | ||
69 | |||
70 | ``` | ||
71 | server { | ||
72 | listen 80; | ||
73 | listen [::]:80; | ||
74 | server_name peertube.example.com; | ||
75 | |||
76 | access_log /var/log/nginx/peertube.example.com.access.log; | ||
77 | error_log /var/log/nginx/peertube.example.com.error.log; | ||
78 | |||
79 | rewrite ^ https://$server_name$request_uri? permanent; | ||
80 | } | ||
81 | |||
82 | server { | ||
83 | listen 443 ssl http2; | ||
84 | listen [::]:443 ssl http2; | ||
85 | server_name peertube.example.com; | ||
86 | |||
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; | ||
91 | |||
92 | access_log /var/log/nginx/peertube.example.com.access.log; | ||
93 | error_log /var/log/nginx/peertube.example.com.error.log; | ||
94 | |||
95 | location ^~ '/.well-known/acme-challenge' { | ||
96 | default_type "text/plain"; | ||
97 | root /var/www/certbot; | ||
98 | } | ||
99 | |||
100 | location / { | ||
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; | ||
105 | |||
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; | ||
111 | send_timeout 600; | ||
112 | } | ||
113 | |||
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; | ||
123 | return 204; | ||
124 | } | ||
125 | |||
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'; | ||
130 | } | ||
131 | |||
132 | alias /var/www/PeerTube/videos; | ||
133 | } | ||
134 | |||
135 | # Websocket tracker | ||
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; | ||
146 | } | ||
147 | } | ||
148 | ``` | ||
149 | |||
150 | |||
151 | Activate the configuration file: | ||
152 | |||
153 | ```bash | ||
154 | $ sudo ln -s /etc/nginx/sites-available/peertube /etc/nginx/sites-enabled/peertube | ||
155 | $ sudo systemctl reload nginx | ||
156 | ``` | ||
157 | |||
158 | ### Systemd | ||
159 | |||
160 | Copy the nginx configuration template: | ||
161 | |||
162 | ```bash | ||
163 | sudo cp /home/peertube/PeerTube/support/systemd/peertube.service /etc/systemd/system/ | ||
164 | ``` | ||
165 | |||
166 | Update the service file: | ||
167 | |||
168 | ```bash | ||
169 | sudo vim /etc/systemd/system/peertube.service | ||
170 | ``` | ||
171 | |||
172 | It should look like this: | ||
173 | |||
174 | ``` | ||
175 | [Unit] | ||
176 | Description=PeerTube daemon | ||
177 | After=network.target | ||
178 | |||
179 | [Service] | ||
180 | Type=simple | ||
181 | Environment=NODE_ENV=production | ||
182 | User=peertube | ||
183 | Group=peertube | ||
184 | ExecStart=/usr/bin/npm start | ||
185 | WorkingDirectory=/home/peertube/PeerTube | ||
186 | StandardOutput=syslog | ||
187 | StandardError=syslog | ||
188 | SyslogIdentifier=peertube | ||
189 | Restart=always | ||
190 | |||
191 | [Install] | ||
192 | WantedBy=multi-user.target | ||
193 | ``` | ||
194 | |||
195 | |||
196 | Tell systemd to reload its config: | ||
197 | |||
198 | ```bash | ||
199 | sudo systemctl daemon-reload | ||
200 | ``` | ||
201 | |||
202 | ### Run | ||
203 | |||
204 | ```bash | ||
205 | sudo systemctl start peertube | ||
206 | sudo journalctl -feu peertube | ||
207 | ``` | ||
208 | |||
209 | ### Administrator | ||
210 | |||
211 | The administrator password is automatically generated and can be found in the | ||
212 | logs. You can set another password with: | ||
213 | |||
214 | ```bash | ||
215 | $ NODE_ENV=production npm run reset-password -- -u root | ||
216 | ``` | ||
217 | |||
218 | ## Upgrade | ||
219 | |||
220 | The following commands will upgrade the source (according to your current | ||
221 | branch), upgrade node modules and rebuild client application: | ||
222 | |||
223 | ```bash | ||
224 | # systemctl stop peertube | ||
225 | $ npm run upgrade-peertube | ||
226 | # systemctl start peertube | ||
227 | ``` | ||