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