Skip to main content

Self-Hosting Guide: Deploy Nextcloud for Your Team

·OSSAlt Team
nextcloudcloud storageself-hostingdockerguide

Self-Hosting Guide: Deploy Nextcloud for Your Team

Nextcloud replaces Dropbox, Google Drive, and Google Workspace. Self-hosting gives you unlimited storage, full data ownership, and collaborative editing — all on your own server.

Requirements

  • VPS with 2 GB RAM minimum (4 GB recommended)
  • Docker and Docker Compose
  • Domain name (e.g., cloud.yourdomain.com)
  • 50+ GB disk (scale to your storage needs)

Step 1: Create Docker Compose

# docker-compose.yml
services:
  nextcloud:
    image: nextcloud:latest
    container_name: nextcloud
    restart: unless-stopped
    ports:
      - "8080:80"
    volumes:
      - nextcloud_data:/var/www/html
    environment:
      - MYSQL_HOST=db
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=your-strong-password
      - NEXTCLOUD_ADMIN_USER=admin
      - NEXTCLOUD_ADMIN_PASSWORD=your-admin-password
      - NEXTCLOUD_TRUSTED_DOMAINS=cloud.yourdomain.com
      - OVERWRITEPROTOCOL=https
      - OVERWRITECLIURL=https://cloud.yourdomain.com
    depends_on:
      - db
      - redis

  db:
    image: mariadb:11
    container_name: nextcloud-db
    restart: unless-stopped
    volumes:
      - db_data:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=your-root-password
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=your-strong-password
    command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW

  redis:
    image: redis:7-alpine
    container_name: nextcloud-redis
    restart: unless-stopped
    volumes:
      - redis_data:/data

volumes:
  nextcloud_data:
  db_data:
  redis_data:

Step 2: Configure Redis Caching

After first start, configure Redis in config.php:

docker exec -it nextcloud bash
apt update && apt install -y nano
nano /var/www/html/config/config.php

Add to the config array:

'memcache.local' => '\\OC\\Memcache\\APCu',
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' => [
    'host' => 'redis',
    'port' => 6379,
],

Step 3: Start Nextcloud

docker compose up -d

Step 4: Reverse Proxy (Caddy)

# /etc/caddy/Caddyfile
cloud.yourdomain.com {
    reverse_proxy localhost:8080
    request_body {
        max_size 10GB
    }
}
sudo systemctl restart caddy

Step 5: DNS

Add an A record: cloud.yourdomain.com → your server IP

Step 6: Install Essential Apps

Navigate to Apps in the top menu:

AppPurpose
Nextcloud OfficeCollaborative document editing (LibreOffice)
CalendarShared team calendars (CalDAV)
ContactsContact management (CardDAV)
TalkVideo calls, screen sharing, chat
MailEmail client built into Nextcloud
DeckKanban boards for task management
NotesMarkdown note-taking
FormsSurveys and forms (Typeform alternative)
CollectivesTeam knowledge base
GroupwareCombined calendar, contacts, mail

Step 7: Configure Background Jobs

Switch from AJAX to cron for reliable background tasks:

# Add to host crontab
*/5 * * * * docker exec -u www-data nextcloud php cron.php

In Administration SettingsBasic settings → set background jobs to Cron.

Step 8: Set Up External Storage (Optional)

Mount S3-compatible storage for scalable file storage:

  1. Enable the External storage support app
  2. Administration SettingsExternal storage
  3. Add S3 bucket with your credentials

Production Hardening

Performance tuning (config.php):

'default_phone_region' => 'US',
'maintenance_window_start' => 1,  // 1 AM UTC
'filelocking.enabled' => true,

Backups:

# Database backup (daily cron)
docker exec nextcloud-db mysqldump -u nextcloud -p nextcloud > /backups/nc-db-$(date +%Y%m%d).sql

# File data backup
docker run --rm -v nextcloud_data:/data -v /backups:/backup alpine \
  tar czf /backup/nc-files-$(date +%Y%m%d).tar.gz /data

Updates:

docker compose pull
docker compose up -d
# Run upgrade inside container
docker exec -u www-data nextcloud php occ upgrade

Monitoring:

  • Monitor port 8080 with Uptime Kuma
  • Set up disk space alerts (storage grows with users)
  • Check /status.php endpoint for health

Resource Usage

UsersRAMCPUDisk
1-102 GB2 cores50 GB
10-504 GB4 cores200 GB
50-1008 GB4 cores500 GB+

VPS Recommendations

ProviderSpec (25 users)Price
Hetzner4 vCPU, 8 GB RAM, 160 GB€8/month
DigitalOcean2 vCPU, 4 GB RAM, 80 GB$24/month
Linode2 vCPU, 4 GB RAM, 80 GB$24/month

Add a separate block storage volume for file data as your team grows.


Compare cloud storage platforms on OSSAlt — features, self-hosting guides, and pricing side by side.