2021-02-25 13:14:04 -05:00
---
title: Installation
description:
published: true
2021-05-23 13:01:19 -04:00
date: 2021-05-23T16:58:48.374Z
2021-02-25 13:14:04 -05:00
tags:
2021-03-14 13:15:53 -04:00
editor: markdown
2021-02-25 13:14:04 -05:00
dateCreated: 2021-02-25T11:24:06.655Z
---
2021-04-06 02:14:48 -04:00
# Installation
2021-02-25 06:20:39 -05:00
2022-02-17 16:11:02 -05:00
Compiling Invidious requires at least 2GB of free RAM (We recommend to have at least 3GB installed).
2021-06-19 10:22:16 -04:00
If you have less (e.g on a cheap VPS) you can setup a SWAP file or partition, so the combined amount is >= 3GB.
2021-02-25 06:20:39 -05:00
After installation take a look at the [Post-install steps ](#post-install-configuration ).
2022-02-17 16:11:02 -05:00
Note: Any [PaaS ](https://en.wikipedia.org/wiki/Platform_as_a_service ) or [SaaS ](https://en.wikipedia.org/wiki/Software_as_a_service ) provider/software (Heroku, YunoHost, Repli...) are unsupported. Use them at your own risk. They **WILL** cause problems with Invidious and might even suspend your account for "abuse" since Invidious is heavy, bandwidth intensive and technically a proxy (and most providers don't like them). If you use one and want to report an issue, please mention which one you use.
2021-07-31 10:18:01 -04:00
2022-02-17 16:11:02 -05:00
## Automated Installation
2021-02-25 06:20:39 -05:00
[Invidious-Updater ](https://github.com/tmiland/Invidious-Updater ) is a self-contained script that can automatically install and update Invidious.
2022-02-17 16:11:02 -05:00
2021-04-06 02:14:48 -04:00
## Docker
2021-02-25 06:20:39 -05:00
2022-02-17 16:11:02 -05:00
> The Invidious docker image is only [available on Quay](https://quay.io/repository/invidious/invidious) because, unlike Docker Hub, [Quay is Free and Open Source Software](https://github.com/quay/quay/blob/master/LICENSE). This is reflected in the `docker-compose.yml` file used in this walk-through.{.is-warning}
2021-05-13 07:39:50 -04:00
2022-02-17 16:11:02 -05:00
Ensure [Docker Engine ](https://docs.docker.com/engine/install ) and [Docker Compose ](https://docs.docker.com/compose/install ) are installed before beginning.
2021-05-13 07:39:50 -04:00
2022-02-17 16:11:02 -05:00
### Docker-compose method (production)
2021-05-13 07:39:50 -04:00
2022-02-17 16:11:02 -05:00
**This method uses the pre-built Docker image from quay**
2021-05-13 07:39:50 -04:00
2022-02-17 16:11:02 -05:00
Note: Currently the repository has to be cloned, this is because the `init-invidious-db.sh` file and the `config/sql` directory have to be mounted to the postgres container (See the volumes section in the docker-compose file below). This "problem" will be solved in the future.
2021-05-13 07:39:50 -04:00
```bash
2022-02-17 16:11:02 -05:00
git clone https://github.com/iv-org/invidious.git
cd invidious
2021-05-13 07:39:50 -04:00
```
2022-02-17 16:11:02 -05:00
Edit the docker-compose.yml with this content:
2021-05-13 07:39:50 -04:00
```docker
version: "2.4"
services:
postgres:
image: postgres:10
restart: always
networks:
- invidious
volumes:
- postgresdata:/var/lib/postgresql/data
- ./config/sql:/config/sql
- ./docker/init-invidious-db.sh:/docker-entrypoint-initdb.d/init-invidious-db.sh
environment:
POSTGRES_DB: invidious
POSTGRES_USER: kemal
POSTGRES_PASSWORD: kemal
healthcheck:
2021-11-08 17:54:45 -05:00
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
2021-05-13 07:39:50 -04:00
invidious:
image: quay.io/invidious/invidious:latest
restart: always
networks:
- invidious
mem_limit: 1024M
cpus: 0.5
ports:
- "127.0.0.1:3000:3000"
environment:
2022-02-17 16:11:02 -05:00
INVIDIOUS_CONFIG: |
# Please read the following file for a comprehensive list of all available
# configuration options and their associated syntax:
# https://github.com/iv-org/invidious/blob/master/config/config.example.yml
2021-05-13 07:39:50 -04:00
channel_threads: 1
check_tables: true
feed_threads: 1
db:
dbname: invidious
user: kemal
password: kemal
host: postgres
port: 5432
full_refresh: false
https_only: false
domain:
# external_port:
2021-10-26 04:14:25 -04:00
healthcheck:
test: wget -nv --tries=1 --spider http://127.0.0.1:3000/api/v1/comments/jNQXAC9IVRw || exit 1
interval: 30s
timeout: 5s
retries: 2
2021-05-13 07:39:50 -04:00
depends_on:
- postgres
2021-10-26 04:14:25 -04:00
autoheal:
restart: always
image: willfarrell/autoheal
environment:
- AUTOHEAL_CONTAINER_LABEL=all
volumes:
- /var/run/docker.sock:/var/run/docker.sock
2021-05-13 07:39:50 -04:00
volumes:
postgresdata:
networks:
invidious:
```
2022-02-17 16:11:02 -05:00
Note: This compose is made for a true "production" setup, where Invidious is behind a reverse proxy. If you prefer to directly access Invidious, replace `127.0.0.1:3000:3000` with `3000:3000` under the `ports:` section.
2021-05-13 07:39:50 -04:00
> The environment variable `POSTGRES_USER` cannot be changed. The SQL config files that run the initial database migrations are hard-coded with the username `kemal`.
{.is-warning}
2021-02-25 06:20:39 -05:00
2022-02-17 16:11:02 -05:00
### Docker-compose method (development)
2021-02-25 06:20:39 -05:00
2022-02-17 16:11:02 -05:00
**This method builds a Docker image from source**
2021-02-25 06:20:39 -05:00
```bash
2022-02-17 16:11:02 -05:00
git clone https://github.com/iv-org/invidious.git
cd invidious
docker-compose up
2021-02-25 06:20:39 -05:00
```
2022-02-17 16:11:02 -05:00
## Manual Installation
2021-02-25 06:20:39 -05:00
2021-04-06 02:14:48 -04:00
### Linux
2021-02-25 06:20:39 -05:00
2022-02-17 16:11:02 -05:00
#### Install Crystal
2021-05-24 07:28:59 -04:00
2021-06-10 15:08:30 -04:00
Follow the instructions for your distribution here: https://crystal-lang.org/install/
2021-05-24 07:28:59 -04:00
2021-06-10 15:08:30 -04:00
#### Install the dependencies
Arch Linux
2021-04-06 02:14:48 -04:00
```bash
2021-06-10 15:08:30 -04:00
sudo pacman -S base-devel librsvg postgresql
```
2021-04-06 02:14:48 -04:00
2022-02-17 16:11:02 -05:00
Debian/Ubuntu
2021-06-10 15:08:30 -04:00
```bash
sudo apt install libssl-dev libxml2-dev libyaml-dev libgmp-dev libreadline-dev postgresql librsvg2-bin libsqlite3-dev zlib1g-dev libpcre3-dev libevent-dev
2021-04-06 02:14:48 -04:00
```
2022-02-17 16:11:02 -05:00
RHEL based and RHEL-like systems (RHEL, Fedora, AlmaLinux, RockyLinux...)
2021-04-06 02:14:48 -04:00
```bash
sudo dnf install -y openssl-devel libevent-devel libxml2-devel libyaml-devel gmp-devel readline-devel postgresql librsvg2-devel sqlite-devel zlib-devel gcc
2021-02-25 06:20:39 -05:00
```
#### Add an Invidious user and clone the repository
```bash
2022-02-17 16:11:02 -05:00
useradd -m invidious
su - invidious
git clone https://github.com/iv-org/invidious
exit
2021-02-25 06:20:39 -05:00
```
#### Set up PostgresSQL
```bash
2022-02-17 16:11:02 -05:00
systemctl enable --now postgresql
sudo -i -u postgres
psql -c "CREATE USER kemal WITH PASSWORD 'kemal';" # Change 'kemal' here to a stronger password, and update `password` in config/config.yml
createdb -O kemal invidious
psql invidious kemal < /home/invidious/invidious/config/sql/channels.sql
psql invidious kemal < /home/invidious/invidious/config/sql/videos.sql
psql invidious kemal < /home/invidious/invidious/config/sql/channel_videos.sql
psql invidious kemal < /home/invidious/invidious/config/sql/users.sql
psql invidious kemal < /home/invidious/invidious/config/sql/session_ids.sql
psql invidious kemal < /home/invidious/invidious/config/sql/nonces.sql
psql invidious kemal < /home/invidious/invidious/config/sql/annotations.sql
psql invidious kemal < /home/invidious/invidious/config/sql/playlists.sql
psql invidious kemal < /home/invidious/invidious/config/sql/playlist_videos.sql
exit
2021-02-25 06:20:39 -05:00
```
#### Set up Invidious
```bash
2022-02-17 16:11:02 -05:00
su - invidious
cd invidious
2022-02-22 18:45:06 -05:00
shards install --production
crystal build src/invidious.cr --release
2022-02-17 16:11:02 -05:00
exit
2021-02-25 06:20:39 -05:00
```
2021-04-06 02:14:48 -04:00
#### Systemd service
2021-02-25 06:20:39 -05:00
```bash
2022-02-17 16:11:02 -05:00
cp /home/invidious/invidious/invidious.service /etc/systemd/system/invidious.service
systemctl enable --now invidious.service
2021-02-25 06:20:39 -05:00
```
2021-04-06 02:14:48 -04:00
### MacOS
2021-02-25 06:20:39 -05:00
```bash
# Install dependencies
2022-02-17 16:11:02 -05:00
brew update
brew install shards crystal postgres imagemagick librsvg
2021-02-25 06:20:39 -05:00
# Clone the repository and set up a PostgreSQL database
2022-02-17 16:11:02 -05:00
git clone https://github.com/iv-org/invidious
cd invidious
brew services start postgresql
psql -c "CREATE ROLE kemal WITH PASSWORD 'kemal';" # Change 'kemal' here to a stronger password, and update `password` in config/config.yml
createdb -O kemal invidious
psql invidious kemal < config / sql / channels . sql
psql invidious kemal < config / sql / videos . sql
psql invidious kemal < config / sql / channel_videos . sql
psql invidious kemal < config / sql / users . sql
psql invidious kemal < config / sql / session_ids . sql
psql invidious kemal < config / sql / nonces . sql
psql invidious kemal < config / sql / annotations . sql
psql invidious kemal < config / sql / privacy . sql
psql invidious kemal < config / sql / playlists . sql
psql invidious kemal < config / sql / playlist_videos . sql
2021-02-25 06:20:39 -05:00
# Set up Invidious
2022-02-17 16:11:02 -05:00
shards update & & shards install & & crystal build src/invidious.cr --release
2021-02-25 06:20:39 -05:00
```
## Post-install configuration:
Detailed configuration available in the [configuration guide ](./Configuration.md ).
2022-02-17 16:11:02 -05:00
Because of various issues Invidious **must** be restarted often, at least once a day, ideally every hour.
2021-02-25 06:20:39 -05:00
If you use a reverse proxy, you **must** configure invidious to properly serve request through it:
2022-02-17 16:11:02 -05:00
`https_only: true` : if you are serving your instance via https, set it to true
2021-02-25 06:20:39 -05:00
`domain: domain.ext` : if you are serving your instance via a domain name, set it here
2022-02-17 16:11:02 -05:00
`external_port: 443` : if you are serving your instance via https, set it to 443
2021-02-25 06:20:39 -05:00
## Update Invidious
2022-02-17 16:11:02 -05:00
#### Updating a Docker install
```bash
docker-compose pull & & docker-compose up & & docker image prune -f
```
#### Update a manual install
```bash
sudo - invidious
cd invidious
shards update & & shards install & & crystal build src/invidious.cr --release
exit
systemctl restart invidious.service
```
2021-02-25 06:20:39 -05:00
## Usage:
```bash
2022-02-17 16:11:02 -05:00
./invidious
2021-02-25 06:20:39 -05:00
```
2022-02-17 16:11:02 -05:00
#### Logrotate configuration
2021-02-25 06:20:39 -05:00
```bash
2022-02-17 16:11:02 -05:00
echo "/home/invidious/invidious/invidious.log {
rotate 4
weekly
notifempty
missingok
compress
minsize 1048576
}" | tee /etc/logrotate.d/invidious.logrotate
chmod 0644 /etc/logrotate.d/invidious.logrotate
```