File Sync & Share
Nextcloud
A self-hosted file sync and share platform, replacing Google Drive and Dropbox with extensive plugin support.
Review notes
PHP and database configuration must be correct. Use PostgreSQL for production, set up cron jobs and Redis for better performance.
Deployment guide
Run with Docker Compose using PostgreSQL and Redis. Domain and trusted_domains must be configured correctly.
- Create data and config directories for Nextcloud.
- Run Docker Compose with Nextcloud, PostgreSQL, and Redis.
- Access the web UI, create an admin account, and configure trusted_domains.
- Set up cron jobs (system cron or webcron) for background tasks.
- Put HTTPS reverse proxy in front and configure overwrite.cli.url.
Backup:Back up the data directory, PostgreSQL database, and config.php. Test restores regularly.
Copy and run on your server
Use each block separately: save the compose file, or copy the bash script to create it and start the container.
docker-compose.ymlyaml
services:
nextcloud:
image: nextcloud:stable
container_name: nextcloud
volumes:
- ./html:/var/www/html
- ./data:/var/www/html/data
environment:
POSTGRES_HOST: postgres
POSTGRES_DB: nextcloud
POSTGRES_USER: nextcloud
POSTGRES_PASSWORD: CHANGEME_db_password # CHANGE THIS
REDIS_HOST: redis
ports:
- "8080:80"
depends_on:
- postgres
- redis
restart: unless-stopped
postgres:
image: postgres:16-alpine
container_name: nextcloud_postgres
environment:
POSTGRES_USER: nextcloud
POSTGRES_PASSWORD: CHANGEME_db_password # CHANGE THIS
POSTGRES_DB: nextcloud
volumes:
- ./postgres:/var/lib/postgresql/data
restart: unless-stopped
redis:
image: redis:7-alpine
container_name: nextcloud_redis
restart: unless-stoppedsetup.shbash
#!/usr/bin/env bash
set -euo pipefail
sudo mkdir -p /opt/nextcloud
sudo chown "$USER":"$USER" /opt/nextcloud
cd /opt/nextcloud
cat > docker-compose.yml <<'COMPOSE'
services:
nextcloud:
image: nextcloud:stable
container_name: nextcloud
volumes:
- ./html:/var/www/html
- ./data:/var/www/html/data
environment:
POSTGRES_HOST: postgres
POSTGRES_DB: nextcloud
POSTGRES_USER: nextcloud
POSTGRES_PASSWORD: CHANGEME_db_password # CHANGE THIS
REDIS_HOST: redis
ports:
- "8080:80"
depends_on:
- postgres
- redis
restart: unless-stopped
postgres:
image: postgres:16-alpine
container_name: nextcloud_postgres
environment:
POSTGRES_USER: nextcloud
POSTGRES_PASSWORD: CHANGEME_db_password # CHANGE THIS
POSTGRES_DB: nextcloud
volumes:
- ./postgres:/var/lib/postgresql/data
restart: unless-stopped
redis:
image: redis:7-alpine
container_name: nextcloud_redis
restart: unless-stopped
COMPOSE
docker compose up -d
echo "Nextcloud is running on http://SERVER_IP:8080"Stack
PHPPostgreSQLDocker