funkwhale/docs/installation/debian.rst

306 wiersze
8.2 KiB
ReStructuredText
Czysty Zwykły widok Historia

Debian and Arch Linux installation
==================================
2017-07-17 20:00:32 +00:00
.. note::
This guide targets Debian 9 (Stretch), which is the latest Debian, as well as Arch Linux.
2017-07-17 20:00:32 +00:00
External dependencies
---------------------
2018-07-01 09:33:55 +00:00
The guides will focus on installing Funkwhale-specific components and
dependencies. However, Funkwhale requires a
2017-07-17 20:00:32 +00:00
: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
default on system. On Debian-like systems, you can install them using:
2017-07-17 20:00:32 +00:00
.. code-block:: shell
sudo apt-get update
sudo apt-get install curl python3-pip python3-venv git unzip
2017-07-17 20:00:32 +00:00
On Arch Linux and its derivatives:
.. code-block:: shell
sudo pacman -S curl python-pip python-virtualenv git unzip
2017-07-17 20:00:32 +00:00
Layout
-------
2018-07-01 09:33:55 +00:00
All Funkwhale-related files will be located under ``/srv/funkwhale`` apart
2017-07-17 20:00:32 +00:00
from database files and a few configuration files. We will also have a
2018-04-26 11:14:44 +00:00
dedicated ``funkwhale`` user to launch the processes we need and own those files.
2017-07-17 20:00:32 +00:00
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
sudo useradd -r -s /usr/bin/nologin -d /srv/funkwhale -m funkwhale
2017-07-17 20:00:32 +00:00
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
2018-07-01 09:33:55 +00:00
└── virtualenv # python dependencies for Funkwhale
2017-07-17 20:00:32 +00:00
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.
2018-07-01 09:33:55 +00:00
Download latest Funkwhale release
2017-07-17 20:00:32 +00:00
----------------------------------
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.
2018-07-01 09:33:55 +00:00
In this guide, we'll assume you want to install the latest version of Funkwhale,
2017-07-17 20:00:32 +00:00
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
2018-03-22 13:19:26 +00:00
mv extracted/api/* api/
rm -rf extracted
2017-07-17 20:00:32 +00:00
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 .
2018-03-22 13:19:26 +00:00
rm -rf extracted
2017-07-17 20:00:32 +00:00
.. note::
You can also choose to get the code directly from the git repo. In this
case, run
cd /srv
rm -r funkwhale
git clone -b master https://code.eliotberriot.com/funkwhale/funkwhale funkwhale
cd funkwhale
The above clone command uses the master branch instead of the default develop branch, as master is stable and more suited for production setups.
You'll also need to re-create the folders we make earlier:
mkdir -p config data/static data/media data/music front
You will still need to get the frontend files as specified before, because
we're not going to build them.
2017-07-17 20:00:32 +00:00
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
A few OS packages are required in order to run Funkwhale. On Debian-like
systems, they can be installed with
2017-07-17 20:00:32 +00:00
.. code-block:: shell
sudo apt install build-essential ffmpeg libjpeg-dev libmagic-dev libpq-dev postgresql-client python3-dev
2017-07-17 20:00:32 +00:00
On Arch, run
.. code-block:: shell
pacman -S $(cat api/requirements.pac)
From now on, you should use the funkwhale user for all commands.
2017-07-17 20:00:32 +00:00
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>`_.
First, create the virtualenv and install wheel:
2017-07-17 20:00:32 +00:00
.. code-block:: shell
python3 -m venv /srv/funkwhale/virtualenv
2018-07-12 18:59:18 +00:00
pip3 install wheel
2017-07-17 20:00:32 +00:00
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
2017-07-17 20:00:32 +00:00
.. important::
Further commands involving python should always be run after you activated
2017-07-17 20:00:32 +00:00
the virtualenv, as described earlier, otherwise those commands will raise
errors
Environment file
----------------
2018-07-01 09:33:55 +00:00
You can now start to configure Funkwhale. The main way to achieve that is by
2017-07-17 20:00:32 +00:00
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/develop/deploy/env.prod.sample"
2017-07-17 20:00:32 +00:00
.. note::
if you used git to get the latest version of the code earlier, you can instead do
cp /srv/funkwhale/deploy/env.prod.sample /srv/funkwhale/config/.env
2017-07-17 20:00:32 +00:00
You can then edit it: the file is heavily commented, and the most relevant
configuration options are mentioned at the top of the file.
2017-07-17 20:00:32 +00:00
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 in that file.
2017-07-17 20:00:32 +00:00
This can be done like this::
export $(cat config/.env | grep -v ^# | xargs)
.. note::
Remember to reload these variables whenever you edit your .env file.
2017-07-17 20:00:32 +00:00
Database setup
---------------
You should now be able to import the initial database structure:
.. code-block:: shell
python api/manage.py migrate
2017-07-17 20:00:32 +00:00
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.
.. 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.
2017-07-17 20:00:32 +00:00
Create an admin account
-----------------------
You can then create your first user account:
.. code-block:: shell
python api/manage.py createsuperuser
2017-07-17 20:00:32 +00:00
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>
2017-07-17 20:00:32 +00:00
Collect static files
--------------------
Static files are the static assets used by the API server (icon PNGs, CSS, etc.).
2018-07-12 18:59:18 +00:00
We need to collect them explicitly, so they can be served by the webserver:
2017-07-17 20:00:32 +00:00
.. code-block:: shell
python api/manage.py collectstatic
2017-07-17 20:00:32 +00:00
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>`.