Destroyed Debian Jessie production installation guide (markdown)
[oweals/peertube.wiki.git] / Ubuntu-16-Production-Installation-Guide.md
1 Credit: https://github.com/Chocobozzz/PeerTube/issues/33
2
3 # Dependencies
4 We need to install dependencies:
5
6     curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
7     sudo add-apt-repository ppa:jonathonf/ffmpeg-3
8     echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
9     sudo apt-get update
10     sudo apt-get dist-upgrade
11     curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
12     sudo apt-get install -y nodejs ffmpeg postgresql-9.5 openssl nginx yarn g++ make
13
14 # Database
15 We need to create the database:
16
17     sudo -u postgres createuser -P peertube
18     sudo -u postgres createdb -O peertube peertube_prod
19
20 # User
21 We need to create the peertube user:
22
23     sudo useradd -m -d /home/peertube -s /bin/bash -p peertube peertube
24
25 And set its password:
26
27     sudo passwd peertube
28
29
30 # Build PeerTube application
31 Master branch is for production, develop branch is for... development.
32
33     sudo su - peertube
34     cd /home/peertube
35     git clone -b master https://github.com/Chocobozzz/PeerTube
36     cd PeerTube
37     yarn install
38     npm run build
39
40 # Configuration files
41 Copy the production configuration file template:
42
43     sudo su - peertube
44     cd /home/peertube/PeerTube/config/
45     cp production.yaml.example production.yaml
46     mv default.yaml default.yaml.bak
47     ln -s production.yaml default.yaml
48     vim production.yaml
49
50 # Webserver
51
52 Create the TLS certificate. (TODO: instructions to install using Let's Encrypt. For now, direct them to https://letsencrypt.org/)
53
54 Copy the nginx configuration template:
55
56     sudo cp /home/peertube/PeerTube/support/nginx/peertube-https /etc/nginx/sites-available/peertube
57
58 Modify the configuration file:
59
60     sudo vim /etc/nginx/sites-available/peertube
61
62 Active the configuration file:
63
64     sudo ln -s /etc/nginx/sites-available/peertube /etc/nginx/sites-enabled/peertube
65     sudo systemctl reload nginx
66
67 # Systemd
68 Copy the service file:
69
70     sudo cp /home/peertube/PeerTube/support/systemd/peertube.service /etc/systemd/system/
71
72 Update the service file:
73
74     sudo vim /etc/systemd/system/peertube.service
75
76 It should look like this: (Note what `Working Directory` is set to)
77
78     [Unit]
79     Description=PeerTube daemon
80
81     [Service]
82     Type=simple
83     Environment=NODE_ENV=production
84     User=peertube
85     Group=peertube
86     ExecStart=/usr/bin/npm start
87     WorkingDirectory=/home/peertube/PeerTube/
88     StandardOutput=syslog
89     StandardError=syslog
90     SyslogIdentifier=peertube
91     Restart=always
92
93     [Install]
94     WantedBy=multi-user.target
95
96 Then tell systemd to reload its config:
97
98     sudo systemctl daemon-reload
99
100 # Run PeerTube
101
102     sudo systemctl start peertube
103     sudo journalctl -feu peertube
104
105 The output from starting peertube for the first time will include the credentials for your instance's administrative account, and this information will not be repeated.  Make note of it.
106
107     sudo systemctl enable peertube