Immich is an open-source, self-hosted photo and video backup solution designed for tech-savvy users who prioritize privacy, customization, and full control over their data. With features like automatic uploads, deduplication, and seamless media organization, itβs a powerful alternative to traditional cloud-based services. This guide will take you through the steps to install, configure, and manage Immich, ensuring you have a robust setup for securely hosting your media.
Installing Immich
π¦ Docker/Docker Compose Setup
Immich is best deployed using Docker for ease of management and portability. Below is a docker-compose.yml
file tailored for Immich, along with commands to bring the app online.
Create a docker-compose.yml
file:
version: '3.8'
services:
immich-server:
image: ghcr.io/immich-app/immich-server:latest
container_name: immich-server
environment:
- IMMICH_DATABASE_URL=postgresql://postgres:password@immich-db/immich
- IMMICH_REDIS_URL=redis://immich-redis:6379
ports:
- "3001:3001"
depends_on:
- immich-db
- immich-redis
restart: unless-stopped
immich-web:
image: ghcr.io/immich-app/immich-web:latest
container_name: immich-web
ports:
- "8080:80"
depends_on:
- immich-server
restart: unless-stopped
immich-db:
image: postgres:14
container_name: immich-db
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
volumes:
- immich_db_data:/var/lib/postgresql/data
restart: unless-stopped
immich-redis:
image: redis:6
container_name: immich-redis
restart: unless-stopped
volumes:
immich_db_data:
Start the containers:
docker-compose up -d
Check the status of the services:
docker ps
π Manual Installation
If you prefer not to use Docker, you can manually install Immich on a Linux server. Here's how:
- Install dependencies:
sudo apt update && sudo apt install -y nodejs npm postgresql redis git
- Clone the Immich repository:
git clone https://github.com/immich-app/immich.git
cd immich
- Start the backend and frontend:
cd server
npm install
npm run start:prod
cd ../web
npm install
npm run start
Configuring Nginx as a Reverse Proxy
π Nginx Configuration
Use Nginx to route traffic to Immich and serve the application securely. Create a server block file at /etc/nginx/sites-available/immich.conf
:
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://localhost:8080; # Immich Web
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /api/ {
proxy_pass http://localhost:3001; # Immich API
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Enable the configuration:
sudo ln -s /etc/nginx/sites-available/immich.conf /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
π SSL/TLS Setup
Secure your Immich instance using Let's Encrypt:
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com
Automate certificate renewals:
sudo systemctl enable certbot.timer
sudo systemctl start certbot.timer
π οΈ Testing and Reloading Nginx
To verify that Nginx is set up correctly:
sudo nginx -t
sudo systemctl reload nginx
Logging and Debugging Immich
ποΈ Enabling Debug Logs
To enable debug-level logs, modify the IMMICH_LOG_LEVEL
environment variable in your docker-compose.yml
:
environment:
- IMMICH_LOG_LEVEL=debug
Restart the containers:
docker-compose restart
π Viewing Logs
For Docker-based installations, check logs with:
docker logs immich-server
docker logs immich-web
For manual setups, check logs in the output of the Node.js processes.
π οΈ Troubleshooting Common Issues
If you encounter errors, search for key terms in the logs. Example:
docker logs immich-server | grep "error"
π€ Exporting Logs
To centralize logs, use a script to send them to an ELK Stack:
docker logs immich-server > immich-server.log
scp immich-server.log user@elk-stack-server:/path/to/logs/
Backup and Restore
ποΈ File-Based Backups
Backup your Immich data and configuration:
tar -czvf immich-backup.tar.gz /path/to/immich_data
π Database Backups
Dump the PostgreSQL database:
docker exec -t immich-db pg_dumpall -c -U postgres > immich-db-backup.sql
To restore:
docker exec -i immich-db psql -U postgres -f immich-db-backup.sql
π Automated Backup Scripts
Automate backups with a cron job:
0 3 * * * tar -czvf /path/to/backups/immich-$(date +\%F).tar.gz /path/to/immich_data
Updating and Upgrading Immich
β¬οΈ Updating Docker Images
Update Immich to the latest version:
docker-compose pull
docker-compose up -d
π οΈ Manual Updates
For manual setups, pull the latest code:
cd immich
git pull
cd server && npm install && npm run build
cd ../web && npm install && npm run build
Restart the services:
pm2 restart immich-server immich-web
π Checking for Updates
Monitor Immichβs GitHub repository for new releases:
git fetch --tags
Leveraging Immichβs Unique Features
π§ Enabling APIs
Enable Immichβs API functionality by ensuring the backend is running. Test with:
curl http://localhost:3001/api/alive
π Advanced Configurations
Customize Immichβs behavior by modifying environment variables in your docker-compose.yml
file. For example:
environment:
- IMMICH_UPLOAD_MAX_FILE_SIZE=100MB
Restart the containers to apply changes:
docker-compose restart
Wrapping Up
By following this guide, youβve successfully deployed, secured, and configured Immich to host your media files with full control and privacy. With powerful features and extensive customization, Immich empowers you to move away from proprietary cloud solutions. Start leveraging the provided examples to fully unlock the potential of Immich in your environment!