How to Self-Host Cloud Storage with Nextcloud

Use Cases 3 min read Updated May 2026

Nextcloud is a powerful, open-source alternative to Google Drive or Dropbox. You get full control over your data, file syncing, photo backup, calendar, contacts, and more - all hosted on your own server.

Prerequisites

Step 1: Install Dependencies

apt update
apt install nginx mysql-server php8.1-fpm php8.1-mysql php8.1-xml php8.1-mbstring \
  php8.1-curl php8.1-zip php8.1-gd php8.1-intl php8.1-bcmath php8.1-imagick \
  php8.1-redis unzip wget -y

Step 2: Configure MySQL

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

Step 3: Download Nextcloud

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

Step 4: Configure PHP

Edit PHP settings for better performance:

nano /etc/php/8.1/fpm/php.ini

Update:

memory_limit = 512M
upload_max_filesize = 10G
post_max_size = 10G
max_execution_time = 300

Restart PHP-FPM:

systemctl restart php8.1-fpm

Step 5: Configure Nginx

nano /etc/nginx/sites-available/nextcloud
server {
    listen 80;
    server_name cloud.yourdomain.com;
    root /var/www/nextcloud;

    add_header X-Content-Type-Options nosniff;
    add_header X-Frame-Options SAMEORIGIN;
    add_header X-XSS-Protection "1; mode=block";

    client_max_body_size 10G;
    fastcgi_buffers 64 4K;

    index index.php index.html;

    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)(\/.*|)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
    }

    location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
        try_files $uri /index.php$request_uri;
        expires 6M;
        add_header Cache-Control "public";
    }

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

Enable and reload:

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

Step 6: Set Up HTTPS

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

Step 7: Complete Installation via Browser

Visit:

https://cloud.yourdomain.com

Fill in:

Click Finish setup.

Step 8: Install the Nextcloud Desktop & Mobile Apps

Download from nextcloud.com/install for:

Enter your server URL to connect and start syncing files.

Useful Nextcloud Apps to Install

From the Nextcloud admin panel → Apps:


Questions? Email us at [email protected] - we reply in under 2 hours, 7 days a week.

Top up in crypto.
Be root in a minute.

No cards. No KYC. Uninterrupted service since 2014. For people who'd rather not explain why they need a server.

Deploy a server →