// ssd vps

How to Install and Configure Nextcloud on a Linux VPS: Complete Guide for a Private Cloud

September 23, 2026 · by Alex M.

How to Install and Configure Nextcloud on a Linux VPS: Complete Guide for a Private Cloud

Nextcloud is one of the most powerful open-source platforms for file storage and team collaboration. Unlike Google Drive or Dropbox, Nextcloud runs on your own server — which means you retain full control over your data, with no third party involved. On an SSD VPS running Ubuntu 22.04, the installation takes less than an hour and delivers a fully functional private cloud with calendar, contacts, and online document editing.

This guide walks you through every step: server preparation, software stack installation (Nginx + MariaDB + PHP 8.2), HTTPS configuration, and essential performance tuning.


Why Host Nextcloud on Your Own VPS?

Commercial cloud services come with well-known trade-offs: limited free-tier storage, questionable privacy policies, and rising costs as your data grows. Running Nextcloud on a NVMe VPS gives you:

  • Full data sovereignty — no third party accesses your files
  • Scalable storage — expand the VPS disk without platform migration
  • Rich feature set — calendar, contacts, online editing (Collabora/OnlyOffice), video calls
  • Custom security policies — 2FA, end-to-end encryption, password rules
  • No per-user subscription fees to external providers

Prerequisites

Before you start, make sure you have:

  • A VPS running Ubuntu 22.04 LTS (minimum 2 vCPU, 2 GB RAM, 20 GB SSD — 4 GB RAM recommended for teams)
  • Root or sudo access via SSH
  • A domain or subdomain pointing to your VPS IP (e.g. cloud.yourdomain.com)
  • An SSL certificate — we'll use the free Let's Encrypt

If you don't have a server yet, you can spin up a SSD VPS at CLIQHOST and be online within minutes.


Step 1 — Update the System and Set the Hostname

Connect to your VPS via SSH and update packages:

sudo apt update && sudo apt upgrade -y
sudo hostnamectl set-hostname cloud.yourdomain.com

Verify the hostname:

hostname -f

Step 2 — Install Nginx

Nextcloud works excellently with Nginx as the web server:

sudo apt install nginx -y
sudo systemctl enable --now nginx

Check the service status:

sudo systemctl status nginx

If UFW is active, allow HTTP and HTTPS traffic:

sudo ufw allow 'Nginx Full'

Step 3 — Install MariaDB and Create the Database

Nextcloud requires a relational database. MariaDB is the recommended choice for performance and compatibility.

sudo apt install mariadb-server -y
sudo systemctl enable --now mariadb
sudo mysql_secure_installation

During mysql_secure_installation, set a strong root password and answer Yes to all security prompts.

Now create the Nextcloud database and user:

sudo mysql -u root -p
CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'ncuser'@'localhost' IDENTIFIED BY 'VerySecurePassword123!';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'ncuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 4 — Install PHP 8.2 and Required Extensions

Nextcloud requires PHP with several extensions. Add the Ondrej PPA repository and install:

sudo apt install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update

sudo apt install php8.2 php8.2-fpm php8.2-mysql php8.2-xml php8.2-gd \
  php8.2-mbstring php8.2-curl php8.2-zip php8.2-intl php8.2-bcmath \
  php8.2-imagick php8.2-redis php8.2-apcu php8.2-cli -y

Tune php.ini for Nextcloud

Edit the PHP-FPM configuration file:

sudo nano /etc/php/8.2/fpm/php.ini

Modify or add these values:

memory_limit = 512M
upload_max_filesize = 1G
post_max_size = 1G
max_execution_time = 300
date.timezone = Europe/Chisinau
opcache.enable = 1
opcache.memory_consumption = 128
opcache.max_accelerated_files = 10000
opcache.revalidate_freq = 1

Restart PHP-FPM:

sudo systemctl restart php8.2-fpm

Step 5 — Download and Install Nextcloud

Download the latest stable Nextcloud release:

cd /tmp
wget https://download.nextcloud.com/server/releases/latest.zip
sudo apt install unzip -y
unzip latest.zip
sudo mv nextcloud /var/www/
sudo chown -R www-data:www-data /var/www/nextcloud
sudo chmod -R 755 /var/www/nextcloud

Create a data directory outside the document root:

sudo mkdir -p /var/nextcloud-data
sudo chown -R www-data:www-data /var/nextcloud-data

Step 6 — Configure Nginx for Nextcloud

Create a new virtual host file:

sudo nano /etc/nginx/sites-available/nextcloud

Add the following configuration (replace cloud.yourdomain.com with your actual domain):

upstream php-handler {
    server unix:/var/run/php/php8.2-fpm.sock;
}

server {
    listen 80;
    server_name cloud.yourdomain.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    server_name cloud.yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/cloud.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/cloud.yourdomain.com/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;

    root /var/www/nextcloud;
    index index.php index.html;

    client_max_body_size 1G;
    fastcgi_buffers 64 4K;

    add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload" always;
    add_header X-Content-Type-Options nosniff;
    add_header X-Frame-Options SAMEORIGIN;
    add_header X-XSS-Protection "1; mode=block";

    location = /robots.txt { allow all; log_not_found off; access_log off; }
    location = /.well-known/carddav { return 301 $scheme://$host/remote.php/dav; }
    location = /.well-known/caldav  { return 301 $scheme://$host/remote.php/dav; }

    location / {
        rewrite ^ /index.php;
    }

    location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ { deny all; }
    location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { deny all; }

    location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|oc[ms]-provider/.+)\.php(?:$|/) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass php-handler;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
    }

    location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
        try_files $uri /index.php$request_uri;
        expires 6M;
        access_log off;
    }

    location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap|mp4|webm)$ {
        try_files $uri /index.php$request_uri;
        access_log off;
    }
}

Enable the site and test the configuration:

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

Step 7 — Obtain an SSL Certificate with Let's Encrypt

Install Certbot:

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

Verify automatic renewal:

sudo certbot renew --dry-run

For business use requiring a commercial certificate (OV/EV), CLIQHOST offers a full range of SSL certificates.

Restart Nginx:

sudo systemctl restart nginx

Step 8 — Complete the Installation via Browser

Open https://cloud.yourdomain.com in your browser. You'll see the Nextcloud setup wizard.

Fill in the fields:

  • Admin username — choose something other than "admin"
  • Admin password — at least 16 characters, mix of letters, numbers, symbols
  • Data directory/var/nextcloud-data
  • Database — MySQL/MariaDB
  • User: ncuser
  • Password: the one set earlier
  • Database: nextcloud
  • Host: localhost

Click Install and wait 2–3 minutes.


Step 9 — Essential Post-Installation Configuration

9.1 Set Up a Cron Job for Background Tasks

Nextcloud recommends cron over AJAX for background jobs:

sudo crontab -u www-data -e

Add the line:

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

Then go to Settings → Administration → Background jobs and select Cron.

9.2 Install and Configure Redis for Caching

Redis significantly speeds up Nextcloud, especially with multiple concurrent users:

sudo apt install redis-server -y
sudo systemctl enable --now redis-server

Edit config.php:

sudo nano /var/www/nextcloud/config/config.php

Add to the configuration array:

'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => [
    'host' => 'localhost',
    'port' => 6379,
],

9.3 Enable gzip Compression in Nginx

Add to /etc/nginx/nginx.conf inside the http {} block:

gzip on;
gzip_types text/plain application/xml application/json text/css application/javascript;
gzip_min_length 1000;

Step 10 — Harden Your Nextcloud Installation

Enable Two-Factor Authentication (2FA)

In Nextcloud Apps, install Two-Factor TOTP Provider and enable it for the admin account.

Block Brute Force Attacks with Fail2Ban

Create a Nextcloud filter:

sudo nano /etc/fail2ban/filter.d/nextcloud.conf
[Definition]
failregex = ^{"reqId":".*","level":2,"time":".*","remoteAddr":"<HOST>","message":"Login failed.*"}
            ^{"reqId":".*","level":2,.*"message":"Trusted domain error.*"}
ignoreregex =

Add the jail to /etc/fail2ban/jail.local:

[nextcloud]
enabled = true
port = 80,443
protocol = tcp
filter = nextcloud
logpath = /var/nextcloud-data/nextcloud.log
maxretry = 5
bantime = 3600
sudo systemctl restart fail2ban

Run the Nextcloud Security Scan

Nextcloud provides a free online scanner at scan.nextcloud.com — enter your URL to get a detailed security report.


Troubleshooting Common Issues

Problem Likely Cause Fix
413 Request Entity Too Large client_max_body_size too small Increase value in nginx.conf
Nextcloud is slow No cache (APCu/Redis) Enable memcache.local
"Trusted domain" warning IP/domain not listed Add to trusted_domains in config.php
Cron not running Wrong permissions Check crontab -u www-data -l
502 Bad Gateway PHP-FPM stopped sudo systemctl restart php8.2-fpm

If server management feels overwhelming, CLIQHOST offers managed server administration — our team handles configuration, monitoring, and maintenance for you.


Conclusion

Nextcloud on a Linux VPS gives you a complete private cloud — file storage, calendar, contacts, and collaborative document editing — without surrendering control of your data to third parties. The Nginx + MariaDB + PHP 8.2 + Redis stack is stable and performant even for teams of 10–50 users.

For the best performance, a NVMe VPS from CLIQHOST provides fast NVMe storage, guaranteed resources, and 24/7 technical support. Have questions about your setup? Contact our team and we'll help you get running quickly.

SHARE
// what clients say

What Our Clients Say

Real reviews from customers who trust CLIQHOST for performance, reliability and expert technical support.

★★★★★

"We moved our online shop from a foreign host and the difference is night and day — pages load instantly and support replies in minutes, in Romanian."

AM
Andrei M.
eCommerce owner · Chișinău
★★★★★

"Migrated 12 client sites to CLIQHOST. Free migration, zero downtime, and the cPanel setup is exactly what my team needed. Highly recommend."

EV
Elena V.
Web agency · Bălți
★★★★★

"Our NVMe VPS handles traffic spikes without a sweat. Full root, local datacenter, and billing in MDL — everything we wanted from a provider."

DC
Dmitri C.
SaaS founder · Chișinău