How to Set Up Self-Hosted Cloud Storage with Nextcloud
Run your own private Google Drive -- files, calendars, contacts, and photo sync, all on hardware you control. No subscriptions, no storage caps, no scanning your data for ads.
What is Nextcloud?
Nextcloud is an open-source alternative to Google Drive, Dropbox, and iCloud. Rather than renting space on someone else's servers and trusting them with your files, you install Nextcloud on your own server -- a Linux box, an old desktop, or a Raspberry Pi -- and your data stays where you put it.
Nextcloud does files, plus a whole app ecosystem on top:
- •Files: Drive-style sync across desktop and mobile, with sharing and version history.
- •Calendar: CalDAV calendar that syncs with phones, Thunderbird, and the like.
- •Contacts: CardDAV address book with sync.
- •Tasks, notes, photos, talk (video chat) -- installable from the built-in app marketplace.
It's free to self-host and the ecosystem is mature. The trick is just to deploy it correctly -- and Docker makes that easier than installing a LAMP stack by hand.
Step 1. Gather Your Requirements
You need a server and Docker. That's it. Here's what works well in practice:
- Server: A Linux box works best. A Raspberry Pi 4/5 with 4-8 GB RAM is great for small households. A cheap VPS ($5-10/month) works too if you want a public-facing setup.
- Storage: An external USB drive or SATA SSD for the media/data files. Don't rely on the Pi's SD card for production data.
- Docker Engine + Docker Compose: Install both from docs.docker.com/get-docker.
- Network: Port forwarding on your router if you want to access from outside your home, OR a tunneling service like Cloudflare Tunnel (no port forwarding).
- A domain name is highly recommended for HTTPS certificates. Use DuckDNS or a cheap .com domain.
Docker Compose ships with modern Docker installs (the docker compose subcommand). Confirm it's working with docker compose version -- if it errors, install the compose plugin separately.
Step 2. Create a docker-compose.yml
Create a directory for Nextcloud and add a compose file. From the terminal on your server:
mkdir ~/nextcloud && cd ~/nextcloud
nano docker-compose.yml
Paste in this configuration (Nextcloud + MariaDB is the standard reliable combo):
services: db: image: mariadb:10.6 restart: always command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW volumes: - ./db:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=change-this-root-password - MYSQL_PASSWORD=nextcloud-db-password - MYSQL_DATABASE=nextcloud - MYSQL_USER=nextcloud app: image: nextcloud:latest restart: always ports: - 8080:80 links: - db volumes: - ./data:/var/www/html environment: - MYSQL_PASSWORD=nextcloud-db-password - MYSQL_DATABASE=nextcloud - MYSQL_USER=nextcloud - MYSQL_HOST=db
A few important notes:
- •Pick strong passwords for both the MariaDB root and the nextcloud user. Replace the placeholder values!
- •The volumes are bind-mounted subdirectories (./db and ./data), so your data lives in real files you can back up with regular tools.
- •Port 8080:80 maps the container's web port to host 8080. Pick any free port if 8080 is in use elsewhere.
- •The Nextcloud official image from Docker Hub runs on Apache + PHP out of the box. It handles cron, OPCache, and the typical setup for you.
Step 3. Start the Stack
With the file in place, bring the stack up in detached mode:
docker compose up -d
Docker will pull both images (~300 MB total) and start them. Watch the status with:
docker compose ps
Both app and db should show "Up". Initial setup takes a minute or two -- MariaDB needs to initialize its system tables. To watch the logs and know when it's ready:
docker compose logs -f app
When you see Apache reporting "Listening on" lines without errors, Nextcloud is ready to accept connections on port 8080.
Step 4. Web Setup and Admin Account
Open a browser and visit:
http://<server-ip>:8080
Replace <server-ip> with your server's LAN IP (check with ip a on Linux). You'll see the Nextcloud installation wizard -- which actually skips most steps because the Docker image already set up the database connection via env vars we set in Step 2. You only need to:
- 1.Choose an admin username and password. Make it something you'll remember, since this is your account to manage everything.
- 2.(Optional) Storage & database section -- you can usually leave it alone because the docker-compose env vars already informed Nextcloud where MariaDB is.
- 3.Click Install. It takes ~30 seconds while Nextcloud creates initial database tables and admin account.
- 4.Once done, you're redirected to the dashboard at /apps/dashboard/.
- 5.In Administration settings > Overview, fix any warnings (e.g. set up Cron, adjust PHP limits, set default_phone_region in config.php).
You can now upload files via the Files app, share links, and create users under Administration. But for daily use across devices, the next step is the sync clients.
Step 5. Install the Desktop Sync Client
The desktop client keeps a folder on your laptop in sync with the server -- just like Dropbox. Grab it from nextcloud.com/install for Windows, macOS, and Linux (AppImage / Flatpak / distro packages).
- 1.Install the client and launch it.
- 2.Click Log in. In the server URL field, enter http://<server-ip>:8080 (or your final HTTPS URL once you've set it up).
- 3.A browser opens -- log in with the admin account you created, and approve the client's access request.
- 4.Pick which folders to sync locally. The default is everything; you can choose specific subfolders to save space.
- 5.Choose a local sync folder on your computer (the default ~/Nextcloud is fine).
- 6.Files now sync bidirectionally -- drop something in the local folder and it appears on the server and other clients within seconds.
The client supports selective sync, file conflict handling, and large file chunking. It's solid for multi-GB libraries on consumer broadband.
Step 6. Install the Mobile App and Sync Photos
Download the Nextcloud app from the Play Store or App Store. Both iOS and Android versions are official and maintained by Nextcloud GmbH.
- 1.Open the app and enter your server URL.
- 2.Log in with your user account -- same as on the web.
- 3.Browse files, share, upload. You can also edit documents right in the app.
- 4.Enable Auto Upload in the app's settings. Choose Camera as source, a target folder (e.g. /Photos/Camera), and the behaviour you want -- Wi-Fi only, on charge only, etc.
- 5.On iOS, grant the app permission to access Photos. On Android, allow file access.
- 6.The app instantiates uploads whenever a new photo is taken or when the phone's on Wi-Fi and charging. It's like a private Google Photos.
Bonus: install the Recognize app from the Nextcloud app store for AI-powered face clustering and object recognition on your photos -- entirely on-device, no Google or Apple in the loop.
Quick Tips
- •Use HTTPS. Even on your LAN, exposing Nextcloud over HTTP is risky. Put a reverse proxy (Caddy/Nginx Proxy Manager) in front, or run a Cloudflare Tunnel for HTTPS without needing to open router ports.
- •Back up the data directory regularly. The bind-mounted ./data and ./db folders are everything. A rsync snapshot to another drive or a backup service like Restic+B2 is plenty.
- •Use the app marketplace -- install Calendar, Contacts, Tasks, Notes, and Talk from the Nextcloud web UI under Apps. The contacts/calendar apps also sync to your phone via CalDAV/CardDAV built into iOS and Android.
- •Set trusted domains in config.php so Nextcloud doesn't refuse requests coming from your domain or tunnel hostname.
- •Configure cron properly. Set up a system cron job calling docker exec -u www-data app php cron.php every 5 minutes. AJAX mode in the browser is unreliable for big libraries.
- •Watch disk usage. Most users underestimate how big their photo library is. Set up an alert when the data volume hits 80%.
- •Update carefully -- Nextcloud's docker image updates are mostly painless but always back up ./data and the database before bumping major versions.
- •Avoid putting server logs in sync folders -- keep your Nextcloud sync folder clean so the desktop client doesn't fight with system files.
Need More Help?
Setting up Nextcloud with HTTPS, a reverse proxy, and reliable backups is where most people get stuck. If you'd like a hand mapping it to your specific hardware and home network, give us a shout -- we can walk through the whole thing live.