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:
| App | Purpose |
|---|---|
| Nextcloud Office | Collaborative document editing (LibreOffice) |
| Calendar | Shared team calendars (CalDAV) |
| Contacts | Contact management (CardDAV) |
| Talk | Video calls, screen sharing, chat |
| Email client built into Nextcloud | |
| Deck | Kanban boards for task management |
| Notes | Markdown note-taking |
| Forms | Surveys and forms (Typeform alternative) |
| Collectives | Team knowledge base |
| Groupware | Combined 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 Settings → Basic settings → set background jobs to Cron.
Step 8: Set Up External Storage (Optional)
Mount S3-compatible storage for scalable file storage:
- Enable the External storage support app
- Administration Settings → External storage
- 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.phpendpoint for health
Resource Usage
| Users | RAM | CPU | Disk |
|---|---|---|---|
| 1-10 | 2 GB | 2 cores | 50 GB |
| 10-50 | 4 GB | 4 cores | 200 GB |
| 50-100 | 8 GB | 4 cores | 500 GB+ |
VPS Recommendations
| Provider | Spec (25 users) | Price |
|---|---|---|
| Hetzner | 4 vCPU, 8 GB RAM, 160 GB | €8/month |
| DigitalOcean | 2 vCPU, 4 GB RAM, 80 GB | $24/month |
| Linode | 2 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.