2021-04-06 08:14:48 +02:00
# Installation
2021-02-25 12:20:39 +01:00
2022-02-17 22:11:02 +01:00
Compiling Invidious requires at least 2GB of free RAM (We recommend to have at least 3GB installed).
2021-06-19 16:22:16 +02: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 12:20:39 +01:00
After installation take a look at the [Post-install steps ](#post-install-configuration ).
2022-02-17 22:11:02 +01: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 16:18:01 +02:00
2022-02-17 22:11:02 +01:00
## Automated Installation
2021-02-25 12:20:39 +01:00
[Invidious-Updater ](https://github.com/tmiland/Invidious-Updater ) is a self-contained script that can automatically install and update Invidious.
2022-02-17 22:11:02 +01:00
2021-04-06 08:14:48 +02:00
## Docker
2021-02-25 12:20:39 +01:00
2022-03-12 23:51:18 +01: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.**
2021-05-13 13:39:50 +02:00
2022-02-17 22:11:02 +01: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 13:39:50 +02:00
2022-02-17 22:11:02 +01:00
### Docker-compose method (production)
2021-05-13 13:39:50 +02:00
2022-02-17 22:11:02 +01:00
**This method uses the pre-built Docker image from quay**
2021-05-13 13:39:50 +02:00
2022-02-17 22:11:02 +01: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 13:39:50 +02:00
```bash
2022-02-17 22:11:02 +01:00
git clone https://github.com/iv-org/invidious.git
cd invidious
2021-05-13 13:39:50 +02:00
```
2022-02-17 22:11:02 +01:00
Edit the docker-compose.yml with this content:
2021-05-13 13:39:50 +02:00
```docker
2022-02-23 21:17:26 +01:00
version: "3"
2021-05-13 13:39:50 +02:00
services:
2022-02-23 21:17:26 +01:00
2021-05-13 13:39:50 +02:00
invidious:
image: quay.io/invidious/invidious:latest
2022-02-23 21:17:26 +01:00
# image: quay.io/invidious/invidious:latest-arm64 # ARM64/AArch64 devices
restart: unless-stopped
2021-05-13 13:39:50 +02:00
ports:
- "127.0.0.1:3000:3000"
environment:
2022-02-17 22:11:02 +01:00
# 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
2022-02-23 21:17:26 +01:00
INVIDIOUS_CONFIG: |
2021-05-13 13:39:50 +02:00
db:
dbname: invidious
user: kemal
password: kemal
2022-02-23 21:17:26 +01:00
host: invidious-db
2021-05-13 13:39:50 +02:00
port: 5432
2022-02-23 21:17:26 +01:00
check_tables: true
# external_port:
# domain:
# https_only: false
# statistics_enabled: false
2021-10-26 10:14:25 +02: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 13:39:50 +02:00
depends_on:
2022-02-23 21:17:26 +01:00
- invidious-db
invidious-db:
image: docker.io/library/postgres:14
restart: unless-stopped
2021-10-26 10:14:25 +02:00
volumes:
2022-02-23 21:17:26 +01:00
- 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:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
2021-05-13 13:39:50 +02:00
volumes:
postgresdata:
```
2022-02-17 22:11:02 +01: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 13:39:50 +02: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 12:20:39 +01:00
2022-02-17 22:11:02 +01:00
### Docker-compose method (development)
2021-02-25 12:20:39 +01:00
2022-02-17 22:11:02 +01:00
**This method builds a Docker image from source**
2021-02-25 12:20:39 +01:00
```bash
2022-02-17 22:11:02 +01:00
git clone https://github.com/iv-org/invidious.git
cd invidious
docker-compose up
2021-02-25 12:20:39 +01:00
```
2022-02-17 22:11:02 +01:00
## Manual Installation
2021-02-25 12:20:39 +01:00
2021-04-06 08:14:48 +02:00
### Linux
2021-02-25 12:20:39 +01:00
2022-02-17 22:11:02 +01:00
#### Install Crystal
2021-05-24 13:28:59 +02:00
2021-06-10 21:08:30 +02:00
Follow the instructions for your distribution here: https://crystal-lang.org/install/
2021-05-24 13:28:59 +02:00
2021-06-10 21:08:30 +02:00
#### Install the dependencies
Arch Linux
2021-04-06 08:14:48 +02:00
```bash
2021-06-10 21:08:30 +02:00
sudo pacman -S base-devel librsvg postgresql
```
2021-04-06 08:14:48 +02:00
2022-02-17 22:11:02 +01:00
Debian/Ubuntu
2021-06-10 21:08:30 +02: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 08:14:48 +02:00
```
2022-02-17 22:11:02 +01:00
RHEL based and RHEL-like systems (RHEL, Fedora, AlmaLinux, RockyLinux...)
2021-04-06 08:14:48 +02: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 12:20:39 +01:00
```
#### Add an Invidious user and clone the repository
```bash
2022-02-17 22:11:02 +01:00
useradd -m invidious
su - invidious
git clone https://github.com/iv-org/invidious
exit
2021-02-25 12:20:39 +01:00
```
#### Set up PostgresSQL
```bash
2022-02-17 22:11:02 +01: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 12:20:39 +01:00
```
#### Set up Invidious
```bash
2022-02-17 22:11:02 +01:00
su - invidious
cd invidious
2022-02-23 00:45:06 +01:00
shards install --production
crystal build src/invidious.cr --release
2022-02-17 22:11:02 +01:00
exit
2021-02-25 12:20:39 +01:00
```
2021-04-06 08:14:48 +02:00
#### Systemd service
2021-02-25 12:20:39 +01:00
```bash
2022-02-17 22:11:02 +01:00
cp /home/invidious/invidious/invidious.service /etc/systemd/system/invidious.service
systemctl enable --now invidious.service
2021-02-25 12:20:39 +01:00
```
2021-04-06 08:14:48 +02:00
### MacOS
2021-02-25 12:20:39 +01:00
```bash
# Install dependencies
2022-02-17 22:11:02 +01:00
brew update
brew install shards crystal postgres imagemagick librsvg
2021-02-25 12:20:39 +01:00
# Clone the repository and set up a PostgreSQL database
2022-02-17 22:11:02 +01: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 12:20:39 +01:00
# Set up Invidious
2022-02-17 22:11:02 +01:00
shards update & & shards install & & crystal build src/invidious.cr --release
2021-02-25 12:20:39 +01:00
```
## Post-install configuration:
Detailed configuration available in the [configuration guide ](./Configuration.md ).
2022-02-17 22:11:02 +01:00
Because of various issues Invidious **must** be restarted often, at least once a day, ideally every hour.
2021-02-25 12:20:39 +01:00
If you use a reverse proxy, you **must** configure invidious to properly serve request through it:
2022-02-17 22:11:02 +01:00
`https_only: true` : if you are serving your instance via https, set it to true
2021-02-25 12:20:39 +01:00
`domain: domain.ext` : if you are serving your instance via a domain name, set it here
2022-02-17 22:11:02 +01:00
`external_port: 443` : if you are serving your instance via https, set it to 443
2021-02-25 12:20:39 +01:00
## Update Invidious
2022-02-17 22:11:02 +01: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 12:20:39 +01:00
## Usage:
```bash
2022-02-17 22:11:02 +01:00
./invidious
2021-02-25 12:20:39 +01:00
```
2022-02-17 22:11:02 +01:00
#### Logrotate configuration
2021-02-25 12:20:39 +01:00
```bash
2022-02-17 22:11:02 +01: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
```