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.compointing 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:latestOpen 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
- 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 - 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';" - 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 - 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. - 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).
Recommended settings after a manual install
- 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 raiseupload_max_filesize/post_max_sizeplus Nginxclient_max_body_sizefor 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 statusTroubleshooting
- Access through untrusted domain: add the domain to
trusted_domainsinconfig.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.
