]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - support/doc/dependencies.md
1973eaae300309e1d140f503069e08e27e73d401
[github/Chocobozzz/PeerTube.git] / support / doc / dependencies.md
1 # Dependencies
2
3 :warning: **Warning**: dependencies guide is maintained by the community. Some parts may be outdated! :warning:
4
5 Follow the below guides, and check their versions match [required external dependencies versions](https://github.com/Chocobozzz/PeerTube/blob/master/engines.yaml).
6
7 Main dependencies version supported by PeerTube:
8
9 * `node` >=14.x
10 * `yarn` >=1.x
11 * `postgres` >=10.x
12 * `redis-server` >=5.x
13 * `ffmpeg` >=4.1
14
15
16 _note_: only **LTS** versions of external dependencies are supported. If no LTS version matching the version constraint is available, only **release** versions are supported.
17
18 <!-- START doctoc generated TOC please keep comment here to allow auto update -->
19 <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
20
21 - [Debian / Ubuntu and derivatives](#debian-ubuntu-and-derivatives)
22 - [Arch Linux](#arch-linux)
23 - [CentOS 7](#centos-7)
24 - [Centos 8](#centos-8)
25 - [Rocky Linux 8.4](#rocky-linux-84)
26 - [Fedora](#fedora)
27 - [Red Hat Enterprise Linux 8](#red-hat-enterprise-linux-8)
28 - [FreeBSD](#freebsd)
29 - [macOS](#macos)
30 - [Gentoo](#gentoo)
31 - [OpenBSD](#openbsd)
32 - [Other distributions](#other-distributions)
33
34 <!-- END doctoc generated TOC please keep comment here to allow auto update -->
35
36 ## Debian / Ubuntu and derivatives
37
38 1. On a fresh Debian/Ubuntu, as root user, install basic utility programs needed for the installation
39
40 ```
41 # apt-get install curl sudo unzip vim
42 ```
43
44 2. It would be wise to disable root access and to continue this tutorial with a user with sudoers group access
45
46 3. Install NodeJS 16.x:
47 [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)
48 4. Install yarn, and be sure to have [a recent version](https://github.com/yarnpkg/yarn/releases/latest):
49 [https://yarnpkg.com/en/docs/install#linux-tab](https://yarnpkg.com/en/docs/install#linux-tab)
50
51 5. Install Python:
52
53 On Ubuntu <= bionic (18.04 LTS) or Debian <= Buster:
54
55 ```
56 sudo apt update
57 sudo apt install python-dev
58 python --version # Should be >= 2.x or >= 3.x
59 ```
60
61 On Ubuntu >= focal (20.04 LTS) or Debian >= Bullseye:
62
63 ```
64 sudo apt update
65 sudo apt install python3-dev python-is-python3 # python-is-python2 should also work
66 python --version # Should be >= 2.x or >= 3.x
67 ```
68
69 6. Install common dependencies:
70
71 ```
72 sudo apt update
73 sudo apt install certbot nginx ffmpeg postgresql postgresql-contrib openssl g++ make redis-server git cron wget
74 ffmpeg -version # Should be >= 4.1
75 g++ -v # Should be >= 5.x
76 redis-server --version # Should be >= 5.x
77 ```
78
79 Now that dependencies are installed, before running PeerTube you should start PostgreSQL and Redis:
80
81 ```
82 sudo systemctl start redis postgresql
83 ```
84
85 ## Arch Linux
86
87 1. Run:
88
89 ```
90 sudo pacman -S nodejs-lts-fermium yarn ffmpeg postgresql openssl redis git wget unzip python base-devel npm nginx
91 ```
92
93 Now that dependencies are installed, before running PeerTube you should start PostgreSQL and Redis:
94
95 ```
96 sudo systemctl start redis postgresql
97 ```
98
99 ## CentOS 7
100
101 1. Install NodeJS 16.x:
102 [https://nodejs.org/en/download/package-manager/#enterprise-linux-and-fedora](https://nodejs.org/en/download/package-manager/#enterprise-linux-and-fedora)
103
104 2. Install yarn:
105 [https://yarnpkg.com/en/docs/install](https://yarnpkg.com/en/docs/install)
106
107 3. Install or compile ffmpeg:
108
109 * Install - [https://linoxide.com/linux-how-to/install-ffmpeg-centos-7/](https://linoxide.com/linux-how-to/install-ffmpeg-centos-7/)
110 * Compile - [https://gist.github.com/mustafaturan/7053900#file-latest-ffmpeg-centos6-sh](https://gist.github.com/mustafaturan/7053900#file-latest-ffmpeg-centos6-sh)
111
112 4. Install Packages:
113
114 ```
115 sudo yum update
116 sudo yum install epel-release centos-release-scl
117 sudo yum update
118 sudo yum install nginx postgresql postgresql-server postgresql-contrib openssl gcc-c++ make wget redis git devtoolset-7
119 ```
120
121 5. You need to use a more up to date version of G++ in order to run the yarn install command, hence the installation of devtoolset-7.
122
123 ```
124 sudo scl enable devtoolset-7 bash
125 ```
126
127 Later when you invoke any node command, please prefix them with `CC=/opt/rh/devtoolset-7/root/usr/bin/gcc CXX=/opt/rh/devtoolset-7/root/usr/bin/g++`, such as with:
128
129 ```
130 sudo -H -u peertube CC=/opt/rh/devtoolset-7/root/usr/bin/gcc CXX=/opt/rh/devtoolset-7/root/usr/bin/g++ yarn install --production --pure-lockfile
131 ```
132
133 6. Initialize the PostgreSQL database:
134
135 ```
136 sudo PGSETUP_INITDB_OPTIONS='--auth-host=md5' postgresql-setup --initdb --unit postgresql
137 ```
138
139 Now that dependencies are installed, before running PeerTube you should enable and start PostgreSQL and Redis:
140
141 ```
142 sudo systemctl enable --now redis
143 sudo systemctl enable --now postgresql
144 ```
145
146 ## Centos 8
147
148 1. Install NodeJS 16.x:
149 [https://nodejs.org/en/download/package-manager/#enterprise-linux-and-fedora](https://nodejs.org/en/download/package-manager/#enterprise-linux-and-fedora)
150
151 2. Install yarn:
152 [https://yarnpkg.com/en/docs/install](https://yarnpkg.com/en/docs/install)
153
154 3. Install or compile ffmpeg:
155
156 ```
157 sudo dnf install epel-release dnf-utils
158 sudo yum-config-manager --set-enabled powertools
159 sudo yum-config-manager --add-repo=https://negativo17.org/repos/epel-multimedia.repo
160 sudo dnf install ffmpeg
161 ```
162
163 4. Install packages:
164
165 ```
166 sudo dnf update
167 sudo dnf install epel-release
168 sudo dnf update
169 sudo dnf install nginx postgresql postgresql-server postgresql-contrib openssl gcc-c++ make wget redis git unzip
170 ```
171
172 5. You'll need a symlink for python3 to python for youtube-dl to work
173
174 ```
175 sudo ln -s /usr/bin/python3 /usr/bin/python
176 ```
177
178 6. Initialize the PostgreSQL database:
179
180 ```
181 sudo PGSETUP_INITDB_OPTIONS='--auth-host=md5' postgresql-setup --initdb --unit postgresql
182 ```
183
184 Now that dependencies are installed, before running PeerTube you should enable and start PostgreSQL and Redis:
185
186 ```
187 sudo systemctl enable --now redis
188 sudo systemctl enable --now postgresql
189 ```
190
191 ## Rocky Linux 8.4
192
193 1. Pull the latest updates:
194 ```
195 sudo dnf update -y
196 ```
197
198 2. Install NodeJS 16.x:
199 ```
200 sudo dnf module install -y nodejs:16
201 ```
202
203 3. Install yarn:
204 ```
205 sudo npm install --global yarn
206 ```
207
208 4. Install or compile ffmpeg (if you want to compile... enjoy):
209 ```
210 sudo dnf install -y epel-release
211 sudo dnf --enablerepo=powertools install -y SDL2 SDL2-devel
212 sudo dnf install -y --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-8.noarch.rpm
213 sudo dnf install -y ffmpeg
214 sudo dnf update -y
215 ```
216
217 5. Install PostgreSQL and Python3 and other stuff:
218 ```
219 sudo dnf install -y nginx postgresql postgresql-server postgresql-contrib openssl gcc-c++ make wget redis git python3
220 sudo ln -s /usr/bin/python3 /usr/bin/python
221 sudo PGSETUP_INITDB_OPTIONS='--auth-host=md5' postgresql-setup --initdb --unit postgresql
222 sudo systemctl enable --now redis
223 sudo systemctl enable --now postgresql
224 ```
225
226 6. Configure the peertube user:
227 ```
228 sudo useradd -m -d /var/www/peertube -s /bin/bash -p peertube peertube
229 ```
230
231 7. Unknown missing steps:
232 - Steps missing here... these were adapted from the CentOS 8 steps which abruptly ended.
233 - /var/www/peertube does not exist yet (expected? done in future steps? documentation?).
234 - Nothing about Certbot, NGINX, Firewall settings, and etc.
235 - Hopefully someone can suggest what is missing here with some hints so I can add it?
236
237 ## Fedora
238
239 1. Upgrade your packages:
240
241 ```
242 dnf upgrade
243 ```
244
245 2. Add a user with sudoers group access:
246
247 ```
248 useradd my-peertube-user
249 passwd my-peertube-user
250 usermod my-peertube-user -a -G wheel # Add my-peertube-user to sudoers
251 su my-peertube-user
252 ```
253
254 3. (Optional) Install certbot (choose instructions for your distribution):
255 [https://certbot.eff.org/all-instructions](https://certbot.eff.org/all-instructions)
256
257 4. Install NodeJS 16.x:
258 [https://nodejs.org/en/download/package-manager/#enterprise-linux-and-fedora](https://nodejs.org/en/download/package-manager/#enterprise-linux-and-fedora)
259
260 5. Install yarn:
261 [https://yarnpkg.com/en/docs/install](https://yarnpkg.com/en/docs/install)
262
263 6. Enable [RPM Fusion](https://rpmfusion.org) for Fedora (available for x86, x86_64, armhfp)
264
265 ```
266 sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
267 ```
268 This is necessary because `ffmpeg` is not in the Fedora repos.
269
270 7. Run:
271
272 ```
273 sudo dnf install nginx ffmpeg postgresql-server postgresql-contrib openssl gcc-c++ make redis git vim
274 ffmpeg -version # Should be >= 4.1
275 g++ -v # Should be >= 5.x
276 redis-server --version # Should be >= 5.x
277 ```
278
279 8. Configure nginx
280
281 ```
282 sudo mkdir /etc/nginx/sites-available
283 sudo mkdir /etc/nginx/sites-enabled
284 sudo ln -s /etc/nginx/sites-enabled/peertube /etc/nginx/conf.d/peertube.conf
285 ```
286
287 9. Post-installation
288
289 _from [PostgreSQL documentation](https://www.postgresql.org/download/linux/redhat/):_
290 > Due to policies for Red Hat family distributions, the PostgreSQL installation will not be enabled for automatic start or have the database initialized automatically.
291
292 ```
293 # PostgreSQL
294 sudo PGSETUP_INITDB_OPTIONS='--auth-host=md5' postgresql-setup --initdb --unit postgresql
295 sudo systemctl enable postgresql.service
296 sudo systemctl start postgresql.service
297 # Nginx
298 sudo systemctl enable nginx.service
299 sudo systemctl start nginx.service
300 # Redis
301 sudo systemctl enable redis.service
302 sudo systemctl start redis.service
303 ```
304
305 10. Firewall
306
307 By default, you cannot access your server via public IP. To do so, you must configure firewall:
308
309 - Ports used by peertube dev setup:
310 ```
311 sudo firewall-cmd --permanent --zone=public --add-port=3000/tcp
312 sudo firewall-cmd --permanent --zone=public --add-port=9000/tcp
313 ```
314 - Optional
315
316 ```
317 sudo firewall-cmd --permanent --zone=public --add-service=http
318 sudo firewall-cmd --permanent --zone=public --add-service=https
319 ```
320
321 - Reload firewall
322
323 ```
324 sudo firewall-cmd --reload
325 ```
326
327 11. Configure max ports
328
329 This is necessary if you are running dev setup, otherwise you will have errors with `nodemon`
330
331 ```
332 echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
333 ```
334
335 [More info](https://stackoverflow.com/questions/34662574/node-js-getting-error-nodemon-internal-watch-failed-watch-enospc#34664097)
336
337 ## Red Hat Enterprise Linux 8
338
339 1. Register system as root user to Red Hat Subscription Management (create a free Red Hat account if you don't have one yet).
340
341 ```
342 # subscription-manager register --username <username> --password <password> --auto-attach
343 # dnf upgrade
344 # reboot
345 ```
346
347 2. Install Node.JS
348
349 ```
350 sudo dnf module install nodejs:16
351 ```
352
353 3. Install Yarn
354
355 ```
356 curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
357 sudo dnf install yarn
358 ```
359
360 4. Install FFmpeg
361
362 ```
363 sudo subscription-manager repos --enable "codeready-builder-for-rhel-8-$(arch)-rpms"
364 sudo dnf install --nogpgcheck https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
365 sudo dnf install --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm
366 sudo dnf upgrade
367 sudo dnf install ffmpeg
368 ```
369
370 5. Run:
371
372 ```
373 sudo dnf install nginx postgresql postgresql-server postgresql-contrib openssl gcc-c++ make wget redis git
374 ```
375
376 6. You'll need a symlink for python3 to python for youtube-dl to work
377
378 ```
379 sudo alternatives --set python3 /usr/bin/python
380 ```
381
382 7. Initialize the PostgreSQL database:
383
384 ```
385 sudo PGSETUP_INITDB_OPTIONS='--auth-host=md5' postgresql-setup --initdb --unit postgresql
386 ```
387
388 Now that dependencies are installed, before running PeerTube you should enable and start PostgreSQL and Redis:
389
390 ```
391 sudo systemctl enable --now redis
392 sudo systemctl enable --now postgresql
393 ```
394
395 If you are running the production guide, you also need to slightly pre-configure nginx, because nginx is packaged differently in the Red Hat family distributions:
396
397 8. Configure nginx
398
399 ```
400 sudo mkdir /etc/nginx/sites-available
401 sudo mkdir /etc/nginx/sites-enabled
402 sudo ln -s /etc/nginx/sites-enabled/peertube /etc/nginx/conf.d/peertube.conf
403 sudo systemctl enable --now nginx
404 ```
405
406 9. Prepare directory
407
408 To add the 'peertube' user, you first have to create the 'www' folder and once the 'peertube' user is added, you have to set the access permissions.
409
410 ```
411 sudo mkdir /var/www
412
413 sudo useradd -m -d /var/www/peertube -s /bin/bash -p peertube peertube
414 sudo passwd peertube
415
416 sudo chmod 755 /var/www/peertube/
417 ```
418
419 10. Firewall
420
421 By default, you cannot access your server via public IP. To do so, you must configure firewall:
422
423 - Ports used by peertube dev setup:
424 ```
425 sudo firewall-cmd --permanent --zone=public --add-port=3000/tcp
426 sudo firewall-cmd --permanent --zone=public --add-port=9000/tcp
427 ```
428 - Optional
429
430 ```
431 sudo firewall-cmd --permanent --zone=public --add-service=http
432 sudo firewall-cmd --permanent --zone=public --add-service=https
433 ```
434
435 - Reload firewall
436
437 ```
438 sudo firewall-cmd --reload
439 ```
440
441 11. Configure max ports
442
443 This is necessary if you are running dev setup, otherwise you will have errors with `nodemon`
444
445 ```
446 echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
447 ```
448
449 [More info](https://stackoverflow.com/questions/34662574/node-js-getting-error-nodemon-internal-watch-failed-watch-enospc#34664097)
450
451
452 ## FreeBSD
453
454 On a fresh install of [FreeBSD](https://www.freebsd.org), new system or new jail:
455
456 1. bootstrap pkg, initialize db and install peertube's dependencies, always as root (sudo not yet installed):
457
458 ```
459 pkg
460 pkg update
461 pkg install -y sudo bash wget git python nginx pkgconf postgresql13-server postgresql13-contrib redis openssl node npm yarn ffmpeg unzip
462 ```
463
464 2. Allow users in the wheel group (hope you don't forgot to add your user on wheel group!) to use sudo.
465
466 ```
467 # visudo
468 ```
469
470 Uncomment the line 90
471
472 ```
473 %wheel ALL=(ALL) ALL
474 ```
475
476 3. Enable nginx, redis, postgresql services and initialize database.
477
478 ```
479 sysrc postgresql_enable="YES"
480 sysrc redis_enable="YES"
481 sysrc nginx_enable="YES"
482 ```
483
484 Initialize database and start services
485
486 ```
487 service postgresql initdb
488 service postgresql start
489 service redis start
490 service nginx start
491 ```
492
493 ## macOS
494
495 1. Add the packages:
496
497 ```sh
498 brew install bash ffmpeg nginx postgresql openssl gcc make redis git yarn
499 ```
500
501 You may need to update your default version of bash.
502
503 **How to change your default shell**
504
505 ```sh
506 which -a bash # Check where bash is installed
507 bash --version # You need a version at least as recent as 4.0
508 sudo vim /etc/shells # Add in this file : /usr/local/bin/bash
509 chsh -s /usr/local/bin/bash # To set the brew-installed bash as default bash
510 ```
511
512 In a new shell, type `bash --version` to assert your changes took effect and
513 correctly modified your default bash version.
514
515 2. Run the services:
516
517 ```sh
518 brew services run postgresql
519 brew services run redis
520 ```
521
522 On macOS, the `postgresql` user can be `_postgres` instead of `postgres`.
523 If `sudo -u postgres createuser -P peertube` gives you an `unknown user: postgres` error, you can try `sudo -u _postgres createuser -U peertube`.
524
525 ## Gentoo
526
527 1. Add this to ``/etc/portage/sets/peertube``:
528
529 ```
530 net-libs/nodejs
531 sys-apps/yarn
532 media-video/ffmpeg[x264] # Optionally add vorbis,vpx
533 dev-db/postgresql
534 dev-db/redis
535 dev-vcs/git
536 app-arch/unzip
537 dev-lang/python
538 dev-lang/python-exec
539 www-servers/nginx
540
541 # Optional, client for Let’s Encrypt:
542 # app-crypt/certbot
543 ```
544
545 2. If you are on a "stable" Gentoo you need to accept the testing keyword ~amd64 yarn:
546
547 ```
548 mkdir -p /etc/portage/package.keywords
549 cat << EOF >> /etc/portage/package.keywords/peertube
550 # required by yarn (argument) for PeerTube
551 sys-apps/yarn ~amd64
552 EOF
553 ```
554
555 3. Compile the peertube set:
556
557 ```
558 emerge -a @peertube
559 ```
560
561 4. Initialize the PostgreSQL database if you just merged it:
562
563 ```
564 emerge --config postgresql
565 ```
566
567 5. (For OpenRC) Enable and then start the services (replace with the correct PostgreSQL slot):
568
569 ```
570 rc-update add redis
571 rc-update add postgresql-11
572 rc-service redis start
573 rc-service postgresql-11 start
574 ```
575
576 6. Create Python version symlink for youtube-dl:
577
578 ```
579 emerge -1 python-exec
580 ```
581
582 ## OpenBSD
583
584 1. Install Packages:
585
586 ```
587 pkg_add sudo bash wget git python nginx pkgconf postgresql-server postgresql-contrib redis openssl
588 ```
589
590 2. Install yarn:
591
592 ```
593 npm install --global yarn
594 ```
595
596 3. Allow users in the wheel group to use sudo
597
598 ```
599 visudo
600 ```
601 Uncomment line #43:
602
603 ```
604 %wheel ALL=(ALL) ALL
605 ```
606
607 4. Enable services:
608
609 ```
610 rcctl enable postgresql redis nginx
611 ```
612
613 ## Other distributions
614
615 Feel free to update this file in a pull request!