urZONE / Deployment Guide

Install Nextcloud on a fresh VM

Run your own file sync and collaboration server using Docker Compose with Nextcloud, MariaDB, and Redis. Follow the steps in order, and use the Copy buttons to send only the commands you need to your terminal.

01 Prepare 02 Deploy 03 Manage

Before you begin

Docker installed

This guide needs Docker Engine and the Compose plugin on an Ubuntu VM. If you have not installed them yet, follow the urZONE Docker guide first.

Recommended resources

At least 2 vCPUs and 4 GB of RAM, plus enough disk for your files and backups. Nextcloud stores user data in a Docker volume, so size the VM disk for the data you expect.

Network

This guide publishes Nextcloud on TCP port 8080 for setup and testing. Put an HTTPS reverse proxy in front before exposing it to the internet.

Run with care: These commands create containers that will hold your files and database. Use a VM you control, take a snapshot first, and choose strong passwords.

Step 01

Connect by SSH

Sign in to the VM as root. Replace the example IP address with your own.

Local terminal · SSH
ssh root@YOUR_SERVER_IP
Root terminal · Check Docker
docker --version && docker compose version
Step 02

Create the project folder

Keep the Nextcloud configuration in its own folder.

Root terminal · Folder
mkdir -p /opt/nextcloud && cd /opt/nextcloud
Step 03

Write the Compose file

Before copying, replace YOUR_SERVER_IP, CHANGE_ME_ROOT, CHANGE_ME_DB, CHANGE_ME_ADMIN, and the admin username as you prefer. Keep the database password identical in both places.

Root terminal · /opt/nextcloud/compose.yaml
cat > compose.yaml <<'EOF'
services:
  db:
    image: mariadb:11
    restart: always
    command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
    volumes:
      - db:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: CHANGE_ME_ROOT
      MYSQL_DATABASE: nextcloud
      MYSQL_USER: nextcloud
      MYSQL_PASSWORD: CHANGE_ME_DB

  redis:
    image: redis:alpine
    restart: always

  app:
    image: nextcloud:apache
    restart: always
    ports:
      - "8080:80"
    depends_on:
      - db
      - redis
    volumes:
      - nextcloud:/var/www/html
    environment:
      MYSQL_HOST: db
      MYSQL_DATABASE: nextcloud
      MYSQL_USER: nextcloud
      MYSQL_PASSWORD: CHANGE_ME_DB
      REDIS_HOST: redis
      NEXTCLOUD_ADMIN_USER: admin
      NEXTCLOUD_ADMIN_PASSWORD: CHANGE_ME_ADMIN
      NEXTCLOUD_TRUSTED_DOMAINS: YOUR_SERVER_IP

volumes:
  db:
  nextcloud:
EOF
chmod 600 compose.yaml

Before running: The Copy button copies the placeholders exactly as shown. Replace them locally, never publish your real passwords, and keep compose.yaml private because it contains them.

Step 04

Start Nextcloud

Pull the images and start the containers in the background. The first start can take a few minutes while Nextcloud installs itself.

Root terminal · /opt/nextcloud
docker compose up -d
docker compose logs -f app

Press Ctrl+C to stop following the logs; the containers keep running. Wait until the log shows Apache is ready.

Step 05

Open your Nextcloud

Open this address in your browser. Make sure TCP port 8080 is permitted through your VM and provider firewalls:

http://YOUR_SERVER_IP:8080

Sign in with the administrator username and password from your Compose file. Replace YOUR_SERVER_IP with your VM’s actual IP address.

If needed

Check status and add a trusted domain

If you see an untrusted domain error when using a hostname, add it with Nextcloud’s occ tool. Replace cloud.example.com with your hostname.

Root terminal · /opt/nextcloud
docker compose exec -u www-data app php occ status
docker compose exec -u www-data app php occ config:system:set trusted_domains 2 --value=cloud.example.com

Keep building

Put Nextcloud behind an HTTPS reverse proxy before using it on the internet, update it by running docker compose pull then docker compose up -d from /opt/nextcloud, and back up the db and nextcloud volumes regularly. Nextcloud upgrades one major version at a time.

References: Nextcloud Docker image · Nextcloud admin manual · Docker Compose