Guides / Nextcloud
Install Nextcloud on a small VPS
Last updated 17 November 2026 · By Mohammad AlSaraf
Nextcloud gives you your own Dropbox-style file storage plus calendar and contacts, on a server you control. We tested the installation on a fresh natbox server on 17 November 2026 with Nextcloud 35.0.3. The HTTPS step needs your own domain and uses certbot's standard Apache setup.
Use Ubuntu 24.04: current Nextcloud needs PHP 8.3 or newer, and Debian 12 ships PHP 8.2. Your storage is your plan's disk (20 GB on Box Plus, 40 GB on Box Max, or add extra disk), so Nextcloud suits documents and photos more than large video libraries.
1. Install Apache, PHP and MariaDB
apt update
apt install -y apache2 libapache2-mod-php mariadb-server bzip2 curl \
php-gd php-mysql php-curl php-mbstring php-intl php-gmp php-bcmath \
php-xml php-zip php-imagick php-apcu
2. Download and check Nextcloud
cd /tmp
curl -fsSLO https://download.nextcloud.com/server/releases/latest.tar.bz2
curl -fsSLO https://download.nextcloud.com/server/releases/latest.tar.bz2.sha256
sha256sum -c --ignore-missing latest.tar.bz2.sha256
tar -xjf latest.tar.bz2 -C /var/www/
chown -R www-data: /var/www/nextcloud
mkdir -p /var/www/nextcloud-data
chown www-data: /var/www/nextcloud-data
chmod 750 /var/www/nextcloud-data
The check must print latest.tar.bz2: OK. The data folder sits outside the web folder, so files can never be downloaded directly.
3. Create the database
DBPW=$(openssl rand -hex 16)
mysql -e "CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER nextcloud@localhost IDENTIFIED BY '$DBPW';
GRANT ALL ON nextcloud.* TO nextcloud@localhost;"
4. Install Nextcloud
cd /var/www/nextcloud
sudo -u www-data php occ maintenance:install \
--database=mysql --database-name=nextcloud --database-user=nextcloud --database-pass="$DBPW" \
--admin-user=admin --admin-pass='choose-a-long-password' \
--data-dir=/var/www/nextcloud-data
sudo -u www-data php occ config:system:set trusted_domains 1 --value=cloud.example.com
sudo -u www-data php occ config:system:set memcache.local --value='\OC\Memcache\APCu'
sudo -u www-data php occ background:cron
Use your own password and domain. It should end with Nextcloud was successfully installed.
5. The web server
cat > /etc/apache2/sites-available/nextcloud.conf <<'EOF'
<VirtualHost *:80>
ServerName cloud.example.com
DocumentRoot /var/www/nextcloud
<Directory /var/www/nextcloud/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
</Directory>
</VirtualHost>
EOF
a2ensite nextcloud
a2dissite 000-default
a2enmod rewrite headers env dir mime
systemctl reload apache2
6. HTTPS
Link your domain in the client area's Domains tab (A record to our address, plus the TXT record shown). Ports 80 and 443 for it then reach your server, and certbot can get a certificate:
apt install -y certbot python3-certbot-apache
certbot --apache -d cloud.example.com
7. Background jobs and upload size
echo "*/5 * * * * php -f /var/www/nextcloud/cron.php" | crontab -u www-data -
sed -i -e 's/^upload_max_filesize = .*/upload_max_filesize = 1G/' \
-e 's/^post_max_size = .*/post_max_size = 1G/' \
-e 's/^memory_limit = .*/memory_limit = 512M/' /etc/php/8.3/apache2/php.ini
systemctl restart apache2
Then log in at https://cloud.example.com and check Administration settings → Overview for any remaining hints.
Good to know
- Install the Nextcloud apps for desktop and phone to sync files; they connect to your domain.
- Back up
/var/www/nextcloud,/var/www/nextcloud-dataand a database dump (mysqldump nextcloud) together (backups guide). - Nextcloud can't send email through ports 25, 465 or 587 here; set its mail server to one that accepts port 2525, or skip email notifications.
- Update from Administration settings → Overview, or with
sudo -u www-data php updater/updater.phar. Take a snapshot first.
Related: self-hosting on a small VPS, Vaultwarden, secure your server.
More guides: Run several apps behind an nginx reverse proxy, Run PostgreSQL on a small server, Host a Python API with FastAPI.