To install Funkwhale on your server, you first need to install its dependencies. We provide all dependencies in a single file to enable you to install everything at once. You can pass the information from this file to `apt` using the following command:
When prompted, hit {kbd}`y` to confirm the install.
That's it! `apt` installs all dependencies and tells you once it has finished.
## 2. Create a Funkwhale user
It's good practice to create a user on your server for Funkwhale administration. Doing this makes it easy to make sure you're running commands from the right place. Follow these steps to set up your user.
1. Create the `funkwhale` user and set its shell to `bash` and its home directory to `/srv/funkwhale`.
2. Create a password for the user. You need to do this so that you can use this user to perform database administration.
```{code} bash
sudo passwd funkwhale
```
3. Finally, give the user `sudo` privileges. You need to do this so that the user can run administrative tasks.
```{code}
usermod -aG sudo funkwhale
```
That's it! You've created your `funkwhale` user. Log in as this user when you want to perform any Funkwhale related tasks.
## 3. Download Funkwhale
Once you've created your `funkwhale` user you can download the Funkwhale software itself.
### Create the directory layout
1. Log in to your `funkwhale` account and go to the `/srv/funkwhale` directory.
```{code} bash
cd /srv/funkwhale
su funkwhale
```
2. Create the directories for Funkwhale.
```{code} bash
mkdir -p config api data/static data/media data/music front
```
That's it! Your directory structure should look like this:
```{code}
.
├── config # config / environment files
├── api # the Funkwhale API
├── data # files served by the API
└── static # storage location for persistent data
└── media # storage location for media files
└── music # storage location for audio files
└── front # frontend files for the user interface
```
### Download the Funkwhale release
Once you've created the directory structure you can download Funkwhale. Funkwhale comes in two parts: the API and the Frontend. You need both to run the application.
You're done! These commands put the software in the correct location for Funkwhale to serve them.
## 4. Install Python dependencies
The Funkwhale API is written in Python. You need to install the API's dependencies to run the software. We use [Poetry](https://python-poetry.org) to handle Python dependencies.
1. Install Poetry. Follow the steps in this wizard to set it up.
7. Your database is ready to be populated! Use the `manage.py` script to create the database structure.
```{code} bash
cd /srv/funkwhale/api
poetry run python manage.py migrate
```
````{note}
You may see the following warning when applying migrations:
```{code}
"Your models have changes that are not yet reflected in a migration, and so won't be applied."
```
You can safely ignore this warning.
````
That's it! You've finished setting up your database.
## 7. Set up Funkwhale
Once you have got your database up and running, you can get Funkwhale ready to launch. Use the built-in `manage.py` script to get things ready.
### Create a superuser for your pod
```{note}
You can create several superusers.
```
To start using Funkwhale, you need to create a superuser for your pod. This user has all the permissions needed to administrate the pod. Follow these steps to create a superuser.
```{code} bash
poetry run python manage.py createsuperuser
```
That's it! You can log in as this user when you finish setting up Funkwhale.
### Collect static files
Funkwhale uses several static assets to serve its frontend. Use `manage.py` to collect these files so that the webserver can serve them.
```{code} bash
poetry run python manage.py collectstatic
```
## 8. Set up systemd unit files
Funkwhale uses [systemd](https://www.freedesktop.org/wiki/Software/systemd/) to manage its services. systemd helps prevent downtime by bringing services back up if they fail. It also starts your Funkwhale services after a reboot. Follow these steps to set up Funkwhale services with systemd.
4. Enable the services. Systemd can then start the services after a reboot.
```{code} bash
sudo systemctl enable funkwhale-server
sudo systemctl enable funkwhale-worker
sudo systemctl enable funkwhale-beat
```
That's it! systemd keeps these services running and starts them up in the correct order after a reboot.
## 9. Set up a reverse proxy
Funkwhale uses a reverse proxy to serve content to users. We use [Nginx](https://nginx.com) to serve this proxy. Follow this guide to install an Nginx configuration using details from your `.env` file.
To enable your users to connect to your pod securely, you need to set up {abbr}`TLS (Transport Layer Security)`. To do this, we recommend using the <acme.sh> script.
1. Download and run `acme.sh`. Replace `my@example.com` with your email address.
```{code} bash
curl https://get.acme.sh | sh -s email=my@example.com
```
2. Generate a certificate. Replace `example.com` with your Funkwhale pod name.