debian.rst 7.96 KB
Newer Older
1
2
Debian and Arch Linux installation
==================================
3
4
5

.. note::

6
    This guide targets Debian 9 (Stretch), which is the latest Debian, as well as Arch Linux.
7
8
9
10

External dependencies
---------------------

Reg's avatar
Reg committed
11
12
The guides will focus on installing Funkwhale-specific components and
dependencies. However, Funkwhale requires a
13
14
15
16
17
18
19
:doc:`few external dependencies <./external_dependencies>` for which
documentation is outside of this document scope.

Install utilities
-----------------

You'll need a few utilities during this guide that are not always present by
20
default on system. On Debian-like systems, you can install them using:
21
22
23
24

.. code-block:: shell

    sudo apt-get update
JocelynDelalande's avatar
JocelynDelalande committed
25
    sudo apt-get install curl python3-pip python3-venv git unzip
26

27
28
29
30
31
On Arch Linux and its derivatives:

.. code-block:: shell

    sudo pacman -S curl python-pip python-virtualenv git unzip
32
33
34
35

Layout
-------

Reg's avatar
Reg committed
36
All Funkwhale-related files will be located under ``/srv/funkwhale`` apart
37
from database files and a few configuration files. We will also have a
Hazmo's avatar
Hazmo committed
38
dedicated ``funkwhale`` user to launch the processes we need and own those files.
39
40
41
42
43
44
45
46
47
48

You are free to use different values here, just remember to adapt those in the
next steps.

.. _create-funkwhale-user:

Create the user and the directory:

.. code-block:: shell

49
    sudo useradd -r -s /usr/bin/nologin -d /srv/funkwhale -m funkwhale
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
    cd /srv/funkwhale

Log in as the newly created user from now on:

.. code-block:: shell

    sudo -u funkwhale -H bash

Now let's setup our directory layout. Here is how it will look like::

    .
    ├── config      # config / environment files
    ├── api         # api code of your instance
    ├── data        # persistent data, such as music files
    ├── front       # frontend files for the web user interface
Reg's avatar
Reg committed
65
    └── virtualenv  # python dependencies for Funkwhale
66
67
68
69
70
71
72
73
74

Create the aforementionned directories:

.. code-block:: shell

    mkdir -p config api data/static data/media data/music front

The ``virtualenv`` directory is a bit special and will be created separately.

Reg's avatar
Reg committed
75
Download latest Funkwhale release
76
77
78
79
80
81
82
83
84
85
86
----------------------------------

Funkwhale is splitted in two components:

1. The API, which will handle music storage and user accounts
2. The frontend, that will simply connect to the API to interact with its data

Those components are packaged in subsequent releases, such as 0.1, 0.2, etc.
You can browse the :doc:`changelog </changelog>` for a list of available releases
and pick the one you want to install, usually the latest one should be okay.

Reg's avatar
Reg committed
87
In this guide, we'll assume you want to install the latest version of Funkwhale,
88
89
90
91
92
93
94
95
which is |version|:

First, we'll download the latest api release.

.. parsed-literal::

    curl -L -o "api-|version|.zip" "https://code.eliotberriot.com/funkwhale/funkwhale/-/jobs/artifacts/|version|/download?job=build_api"
    unzip "api-|version|.zip" -d extracted
96
    mv extracted/api/* api/
JocelynDelalande's avatar
JocelynDelalande committed
97
    rm -rf extracted
98
99
100
101
102
103
104
105
106


Then we'll download the frontend files:

.. parsed-literal::

    curl -L -o "front-|version|.zip" "https://code.eliotberriot.com/funkwhale/funkwhale/-/jobs/artifacts/|version|/download?job=build_front"
    unzip "front-|version|.zip" -d extracted
    mv extracted/front .
107
    rm -rf extracted
108
109
110
111
112
113
114
115
116
117
118
119
120

You can leave the ZIP archives in the directory, this will help you know
which version you've installed next time you want to upgrade your installation.

System dependencies
-------------------

First, switch to the api directory:

.. code-block:: shell

    cd api

121
122
123
124
A few OS packages are required in order to run Funkwhale. On Debian-like
 systems, the list is available in ``api/requirements.apt`` or by running
``./install_os_dependencies.sh list`` and in ``api/requirements.pac`` on
Arch.
125
126
127
128
129
130
131
132

.. note::

    Ensure you are running the next commands as root or using sudo
    (and not as the funkwhale) user.

You can install those packages all at once:

133
134
On Debian-like systems:

135
136
137
138
.. code-block:: shell

    ./install_os_dependencies.sh install

139
140
141
142
143
144
On Arch Linux and its derivatives:

.. code-block:: shell

    pacman -S $(cat api/requirements.pac)

145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
From now on you can switch back to the funkwhale user.

Python dependencies
--------------------

Go back to the base directory:

.. code-block:: shell

    cd /srv/funkwhale

To avoid collisions with other software on your system, Python dependencies
will be installed in a dedicated
`virtualenv <https://docs.python.org/3/library/venv.html>`_.

160
First, create the virtualenv and install wheel:
161
162
163
164

.. code-block:: shell

    python3 -m venv /srv/funkwhale/virtualenv
165
    pip install wheel
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186

This will result in a ``virtualenv`` directory being created in
``/srv/funkwhale/virtualenv``.

In the rest of this guide, we'll need to activate this environment to ensure
dependencies are installed within it, and not directly on your host system.

This is done with the following command:

.. code-block:: shell

    source /srv/funkwhale/virtualenv/bin/activate

Finally, install the python dependencies:

.. code-block:: shell

    pip install -r api/requirements.txt

.. important::

187
    Further commands involving python should always be run after you activated
188
189
190
191
192
193
194
    the virtualenv, as described earlier, otherwise those commands will raise
    errors


Environment file
----------------

Reg's avatar
Reg committed
195
You can now start to configure Funkwhale. The main way to achieve that is by
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
adding an environment file that will host settings that are relevant to your
installation.

Download the sample environment file:

.. parsed-literal::

    curl -L -o config/.env "https://code.eliotberriot.com/funkwhale/funkwhale/raw/|version|/deploy/env.prod.sample"

You can then edit it: the file is heavily commented, and the most relevant
configuration options are mentionned at the top of the file.

Especially, populate the ``DATABASE_URL`` and ``CACHE_URL`` values based on
how you configured your PostgreSQL and Redis servers in
:doc:`external dependencies <./external_dependencies>`.


When you want to run command on the API server, such as to create the
database or compile static files, you have to ensure you source
the environment variables.

This can be done like this::

    export $(cat config/.env | grep -v ^# | xargs)

The easier thing to do is to store this in a script::

    cat > /srv/funkwhale/load_env <<'EOL'
    #!/bin/bash
    export $(cat /srv/funkwhale/config/.env | grep -v ^# | xargs)
    EOL
    chmod +x /srv/funkwhale/load_env

You should now be able to run the following to populate your environment
variables easily:

.. code-block:: shell

    source /srv/funkwhale/load_env

.. note::

    Remember to source ``load_env`` whenever you edit your .env file.

Database setup
---------------

You should now be able to import the initial database structure:

.. code-block:: shell

    python api/manage.py migrate

This will create the required tables and rows.

.. note::

    You can safely execute this command any time you want, this will only
    run unapplied migrations.

256
257
258
259
260
261
262
263
.. warning::

    You may sometimes get the following warning while applying migrations::

        "Your models have changes that are not yet reflected in a migration, and so won't be applied."

    This is a warning, not an error, and it can be safely ignored.
    Never run the ``makemigrations`` command yourself.
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301

Create an admin account
-----------------------

You can then create your first user account:

.. code-block:: shell

    python api/manage.py createsuperuser

If you ever want to change a user's password from the command line, just run:

.. code-block:: shell

    python api/manage.py changepassword <user>

Collect static files
--------------------

Static files are the static assets used by the API server (icon PNGs, CSS, etc.).
We need to collect them explicitely, so they can be served by the webserver:

.. code-block:: shell

    python api/manage.py collectstatic

This should populate the directory you choose for the ``STATIC_ROOT`` variable
in your ``.env`` file.

Systemd unit file
------------------

See :doc:`./systemd`.

Reverse proxy setup
--------------------

See :ref:`reverse-proxy <reverse-proxy-setup>`.