TutorialsJune 18, 20263 min read

How to self-host Nextcloud on a VPS

Own your files with Nextcloud — a private Dropbox/Google Drive alternative on your VPS. Learn to install it, connect a database, and secure it with HTTPS.

NBy Nxeon

Nextcloud is a self-hosted alternative to Dropbox and Google Drive: file sync, sharing, calendars, contacts and more, running entirely on your own server. Self-hosting it on a VPS means your files are genuinely private — no third party can mine them, and storage is limited only by your disk. Here's how to set it up.

What you'll need

  • A VPS with 2 GB+ RAM and enough NVMe storage for your files (pick a larger disk plan if you'll store real data).
  • A domain pointing at the server.
  • Ubuntu (used here) with a LEMP or LAMP stack.

Step 1: Install the stack

sudo apt update && sudo apt upgrade -y
sudo apt install nginx mariadb-server php-fpm php-mysql php-gd php-curl php-mbstring php-xml php-zip php-bcmath php-intl php-imagick unzip -y

Nextcloud is PHP-heavy on features, so those PHP modules matter.

Step 2: Create the database

sudo mysql_secure_installation
sudo mysql

Then:

CREATE DATABASE nextcloud;
CREATE USER 'ncuser'@'localhost' IDENTIFIED BY 'a-strong-password';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'ncuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 3: Download Nextcloud

cd /tmp
curl -O https://download.nextcloud.com/server/releases/latest.zip
unzip latest.zip
sudo mv nextcloud /var/www/nextcloud
sudo chown -R www-data:www-data /var/www/nextcloud

Step 4: Configure Nginx

Create /etc/nginx/sites-available/nextcloud with a basic server block:

server {
    listen 80;
    server_name cloud.example.com;
    root /var/www/nextcloud;
    index index.php;
    client_max_body_size 512M;

    location / {
        try_files $uri $uri/ /index.php$request_uri;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php-fpm.sock;
    }
}

The client_max_body_size line lets you upload large files. Enable and reload:

sudo ln -s /etc/nginx/sites-available/nextcloud /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx

Step 5: Tune PHP for large uploads

Edit your PHP-FPM php.ini and raise these limits so big files and the setup wizard work smoothly:

upload_max_filesize = 512M
post_max_size = 512M
memory_limit = 512M

Then restart PHP-FPM:

sudo systemctl restart php*-fpm

Step 6: Add HTTPS

Point cloud.example.com at your VPS, then secure it — never run a file cloud over plain HTTP:

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d cloud.example.com

Step 7: Run the web setup

Open https://cloud.example.com in a browser. Create an admin account and enter the database details from Step 2 (database nextcloud, user ncuser, your password, host localhost). Nextcloud initializes and drops you into your new private cloud.

Step 8: Set up background jobs

For reliability, switch Nextcloud's background tasks from AJAX to system cron. Add a cron entry for the web user:

sudo crontab -u www-data -e

Add:

*/5 * * * * php -f /var/www/nextcloud/cron.php

Then set "Cron" as the background job method in Nextcloud's admin settings.

Step 9: Install the sync clients

Grab the desktop and mobile apps from Nextcloud, point them at your domain, and your files sync automatically — just like a commercial cloud, but yours.

Why a VPS is ideal for Nextcloud

Your storage size, your privacy, no per-seat fees. A Nxeon VPS with a larger NVMe disk gives you fast, roomy storage with full root to tune PHP and caching. Add Redis for file-locking performance as you grow, keep it backed up, and you've replaced a subscription cloud with one you fully own.

#nextcloud#self-hosting#privacy#vps#cloud-storage

Deploy your first server in under a minute

No credit card required to get started. Spin up a VPS, break things, and only pay for what you keep running.