Websites & apps

Install Nextcloud on a Linux VPS (manual or Docker AIO)

Self-host Nextcloud on a VPS: choose between the Docker All-in-One image and a manual LEMP install, then configure cron, Redis caching, upload limits and security checks.

IntermediateLinux VPS3 min read

Nextcloud is a self-hosted alternative to Dropbox and Google Drive with file sync, calendars, contacts and office editing. On a VPS you control storage and privacy. This guide shows two ways to install Nextcloud on a Linux VPS: the official Docker All-in-One (easiest) and a manual install for full control.

Before you start

  • A VPS with at least 2 GB RAM (4 GB if you add office editing), enough disk for your files, and root access.
  • A subdomain such as cloud.example.com pointing to the VPS.
  • For a simpler setup on cPanel hosting, Softaculous can install Nextcloud too.

Option 1: Nextcloud All-in-One (Docker)

AIO runs Nextcloud with its database, Redis, backups and optional office server, managed from a web interface. With Docker installed and ports 80, 443 and 8080 free:

docker run --init --sig-proxy=false --name nextcloud-aio-mastercontainer --restart always --publish 80:80 --publish 8080:8080 --publish 8443:8443 --volume nextcloud_aio_mastercontainer:/mnt/docker-aio-config --volume /var/run/docker.sock:/var/run/docker.sock:ro nextcloud/all-in-one:latest

Open https://SERVER-IP:8080, note the passphrase it shows, enter your domain and pick optional containers. AIO obtains the SSL certificate and starts everything. It also includes BorgBackup-based backups you configure in the same interface. Check the AIO documentation if you already run a reverse proxy on ports 80/443.

Option 2: Manual install on Nginx and PHP-FPM

  1. Install the stack (Ubuntu example; use the PHP version Nextcloud currently supports):
    apt install nginx mariadb-server redis-server php8.3-fpm php8.3-mysql php8.3-gd php8.3-curl php8.3-mbstring php8.3-intl php8.3-xml php8.3-zip php8.3-bcmath php8.3-gmp php8.3-imagick php8.3-redis php8.3-apcu unzip
  2. Create the database:
    mysql -e "CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'strong-password'; GRANT ALL ON nextcloud.* TO 'nextcloud'@'localhost';"
  3. Download and unpack Nextcloud:
    cd /var/www && wget https://download.nextcloud.com/server/releases/latest.zip && unzip latest.zip && chown -R www-data:www-data nextcloud
  4. Configure Nginx using the server block from the Nextcloud admin manual (it contains essential rules for .well-known, denied paths and PHP handling), then add SSL with Certbot.
  5. Open https://cloud.example.com, create the admin account, and enter the database details. Put the data directory outside the web root, e.g. /srv/nextcloud-data (owned by www-data).
  • Background jobs via cron: in Administration settings → Basic settings choose Cron, and add for www-data:
    */5 * * * * php -f /var/www/nextcloud/cron.php
  • Memory caching: in config/config.php:
    'memcache.local' => '\OC\Memcache\APCu',
    'memcache.locking' => '\OC\Memcache\Redis',
    'redis' => ['host' => '127.0.0.1', 'port' => 6379],
  • PHP limits: memory_limit = 512M, and raise upload_max_filesize/post_max_size plus Nginx client_max_body_size for large uploads.
  • OPcache: enable and give it enough memory (opcache.memory_consumption=128).

Check your installation

Administration settings → Overview lists security and setup warnings; work through them until it shows a green check. The occ command helps too:

sudo -u www-data php /var/www/nextcloud/occ status

Troubleshooting

  • Access through untrusted domain: add the domain to trusted_domains in config.php.
  • Uploads fail at a certain size: PHP or Nginx limits, or Cloudflare's upload limit if proxied.
  • Stuck in maintenance mode: sudo -u www-data php occ maintenance:mode --off.
  • Slow file listings: Redis and APCu not configured, or background jobs set to AJAX.

Nextcloud FAQ

How much storage do I need?

Your files plus versions and trash; plan at least 1.5× the data you expect to store, or attach external/object storage.

Should I update through the web updater?

For manual installs, use the updater or occ upgrade after a backup; AIO updates containers from its interface. Never skip a major version.

Nextcloud or ownCloud?

Nextcloud is a fork of ownCloud with a larger app ecosystem and very active development.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.