2021-04-06 08:14:48 +02:00
# Installation
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-08-31 10:48:28 +02:00
## Hardware requirements
2022-09-23 00:24:45 +02:00
Running Invidious requires at least 512MB of free RAM (so ~2G installed on the system), as long as it is restarted regularly, as recommended in the post-install configuration. Public instances should ideally have at least 4GB of RAM, 2vCPU, a 200 mbps link and 20TB of traffic (no data cap/unlimited traffic is preferred).
2022-08-31 10:48:28 +02:00
Compiling Invidious requires at least 2.5GB of free RAM (We recommend to have at least 4GB installed).
If you have less (e.g on a cheap VPS) you can setup a SWAP file or partition, so the combined amount is >= 4GB.
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
2023-07-03 23:13:17 +02:00
hmac_key: "CHANGE_ME!!"
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
2022-12-08 12:52:18 +01:00
logging:
options:
max-size: "1G"
max-file: "4"
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-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
2022-04-26 23:35:37 +02:00
Note: Invidious currently supports the following Crystal versions: `1.4.0` / `1.3.X` / `1.2.X`
2022-04-09 14:22:42 +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
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-11-02 10:36:33 +01:00
make
2022-11-25 15:48:31 +01:00
# Configure config/config.yml as you like
2022-10-03 15:50:49 +02:00
cp config/config.example.yml config/config.yml
2022-11-25 15:48:31 +01:00
# Deploy the database
./invidious --migrate
2022-02-17 22:11:02 +01:00
exit
2021-02-25 12:20:39 +01:00
```
2022-07-29 11:40:35 +02:00
Note: If the command `crystal build` didn't work properly, you can build Invidious without lsquic may solve compatibilities issues:
```bash
crystal build src/invidious.cr -Ddisable_quic --release
```
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
2022-07-29 11:40:35 +02:00
#### Install the dependencies
2021-02-25 12:20:39 +01:00
```bash
2022-02-17 22:11:02 +01:00
brew update
brew install shards crystal postgres imagemagick librsvg
2022-07-29 11:40:35 +02:00
```
2021-02-25 12:20:39 +01:00
2022-07-29 11:40:35 +02:00
#### Set up PostgresSQL
```bash
2022-02-17 22:11:02 +01:00
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
2022-07-29 11:40:35 +02:00
```
2021-02-25 12:20:39 +01:00
2022-07-29 11:40:35 +02:00
#### Set up Invidious
```bash
git clone https://github.com/iv-org/invidious
cd invidious
shards install --production
crystal build src/invidious.cr --release
2022-10-03 15:50:49 +02:00
cp config/config.example.yml config/config.yml
# Configure config/config.yml how you want
2021-02-25 12:20:39 +01:00
```
2022-07-29 11:40:35 +02:00
Note: If the command `crystal build` didn't work properly, you can build Invidious without lsquic may solve compatibilities issues:
```bash
crystal build src/invidious.cr -Ddisable_quic --release
```
### Windows
Crystal, the programming language used by Invidious, [doesn't support Windows yet ](https://github.com/crystal-lang/crystal/issues/5430 ) but you can still install Invidious through two kinds of ways:
- By installing [Docker desktop ](https://docs.docker.com/desktop/install/windows-install/ ) and then following [our guide about Docker ](#docker ).
- By installing [Windows Subsystem for Linux ](https://msdn.microsoft.com/en-us/commandline/wsl/about ) and then following [our guide about Linux ](#linux ).
2021-02-25 12:20:39 +01:00
## Post-install configuration:
2022-03-29 16:49:09 +02:00
Detailed configuration available in the [configuration guide ](./configuration.md ).
2021-02-25 12:20:39 +01:00
2023-01-06 19:11:37 +01:00
You must set a random generated value for the parameter `hmac_key:` ! On Linux you can generate it using the command `pwgen 20 1` .
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
2022-04-29 17:12:28 +02:00
docker-compose pull
docker-compose up -d
docker image prune -f
2022-02-17 22:11:02 +01:00
```
#### Update a manual install
```bash
2023-05-26 11:50:07 +02:00
su - invidious
2022-02-17 22:11:02 +01:00
cd invidious
2022-04-29 17:12:28 +02:00
git pull
2023-05-26 22:14:09 +02:00
make
2022-02-17 22:11:02 +01:00
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
```