Nextcloud — Self-Hosted Cloud Storage
Nextcloud is an open-source platform for self-hosted file storage and collaboration — a privacy-respecting alternative to Google Drive, Dropbox, and iCloud where all your data stays on your own hardware. It goes well beyond file storage: the app ecosystem includes Calendar (CalDAV), Contacts (CardDAV), Talk (video calls and messaging), Collabora/OnlyOffice integration for document editing, notes, tasks, and hundreds more apps from the Nextcloud App Store.
On localhost or a home server, Nextcloud typically runs on port 8080 (via Docker) or port 80 via Apache. Mobile and desktop sync clients connect to whatever address and port you expose.
Install with Docker Compose (Recommended)
The simplest reliable setup — Nextcloud + MySQL with persistent data:
services:
nextcloud:
image: nextcloud:latest
ports:
- "8080:80"
volumes:
- nextcloud_data:/var/www/html
environment:
- MYSQL_HOST=db
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_PASSWORD=nextcloud_pass
- NEXTCLOUD_ADMIN_USER=admin
- NEXTCLOUD_ADMIN_PASSWORD=changeme
depends_on:
- db
db:
image: mysql:8
volumes:
- db_data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=rootpass
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_PASSWORD=nextcloud_pass
volumes:
nextcloud_data:
db_data:
docker compose up -d
# → Open http://localhost:8080
Nextcloud AIO (All-in-One)
Nextcloud's official All-in-One image is their recommended approach for new installs. It handles orchestrating all components (Nextcloud, database, Redis, talk TURN server, backup) automatically:
docker run -d \
--name nextcloud-aio-mastercontainer \
--restart always \
-p 8080:8080 \
--volume nextcloud_aio_mastercontainer:/mnt/docker-aio-config \
nextcloud/all-in-one:latest
Open localhost:8080 — the AIO interface walks you through setup and generates all other containers.
First-Time Setup
- Open
http://localhost:8080 - Create an admin username and password
- Choose storage backend (SQLite for testing, MySQL/PostgreSQL for production)
- Nextcloud initializes and loads the main Files interface
- Go to Apps (top menu) to install Calendar, Contacts, Talk, and other apps
Connecting Desktop Sync
- Download the Nextcloud desktop app from nextcloud.com/install
- Click Log in and enter your server URL (
http://localhost:8080for local, or your domain if remotely accessible) - Authenticate and choose which folders to sync
- Syncing runs continuously in the background
Performance Tuning
Default Nextcloud is functional but not fast. For better performance:
- Redis for memory caching — add a Redis container and configure
config.phpto use it as APCu/Redis cache - Use MySQL/PostgreSQL instead of SQLite — SQLite degrades significantly with many files
- Run maintenance jobs as a cron — set up a proper crontab or Docker cron instead of AJAX background jobs
- Enable OPcache — ensure PHP OPcache is enabled and adequately sized in php.ini
Troubleshooting
| Problem | Fix |
|---|---|
| Trusted domain error after accessing via IP | Add your IP to trusted_domains in config/config.php |
| Upload size limited to 2MB | Increase PHP upload_max_filesize and post_max_size in php.ini |
| Slow with many files | Switch from SQLite to MySQL — run occ db:convert-type mysql |
| Can't connect from phone on LAN | Use your machine's local IP (192.168.x.x:8080), not localhost — localhost only works on the same device |
| Run maintenance commands | docker exec -u www-data nextcloud php occ [command] |