⌂ Self-hosting

Nextcloud at home: your personal cloud for files and calendars

How to install and configure Nextcloud at home: database, Redis cache, cron, useful apps and the common mistakes that make a personal cloud feel slow.

Nextcloud is often the first service people try when they decide to take back their data: it promises to replace file storage, device sync, calendars, contacts and even an office suite in one go. It works, and works well, but only if it is installed thoughtfully. Many of the complaints you read ("it's slow", "uploads get stuck", "updates break everything") come from configurations left half-finished.

What you really need

Nextcloud is a PHP application that relies on four components:

  • a web server with PHP (Apache, or Nginx with PHP-FPM);
  • a database: MariaDB/MySQL or PostgreSQL. SQLite is acceptable only for testing, because with several users and many files it becomes a bottleneck;
  • an in-memory cache, typically Redis, used both for caching and for file locking;
  • periodic execution of background jobs, best handled by the system cron.

For family use, a mini PC with 4-8 GB of RAM and an SSD for the system and database is enough. User files can live on larger disks, but the database must sit on fast storage: that is where the responsiveness of the interface is decided.

Docker or a classic install

There are two main routes. The first is the Nextcloud All-in-One image, maintained by the project, which starts and manages the required containers on its own, including backups and updates. It is the simplest choice for anyone who wants a working result without tuning every parameter. The second is to assemble the containers by hand (application, database, Redis, proxy) or install everything directly on the operating system: more work, but full control.

In my work I recommend All-in-One to people starting from scratch, and the manual setup to those who already run other containers and want consistent backups and monitoring.

The configuration that makes the difference

After the first start, the Administration settings → Overview page shows a list of warnings. Fix all of them, because each one corresponds to a real problem.

  1. System cron. By default, background jobs run when someone visits a page (AJAX mode). With system cron they run every five minutes regardless of traffic: previews, notifications and cleanups do not pile up.
  2. Redis for locking. Without in-memory locking, the database is used to manage file locks, and during heavy syncing you get "file is locked" errors.
  3. OPcache and PHP limits. Raising memory_limit (at least 512 MB) and configuring OPcache noticeably reduces response times.
  4. Maximum upload size. The desktop client uploads large files in chunks, but the web interface and the proxy in front of Nextcloud must accept suitably sized requests: a limit set too low in the reverse proxy produces baffling errors.
  5. Trusted domain. The trusted_domains parameter in config.php must contain exactly the name you use to connect, otherwise Nextcloud rejects the connection.

A minimal example of entries to check in config.php:

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

Apps worth installing

Nextcloud has a huge app catalogue, but the more you install, the more things can break during updates. A sensible set for a family:

App What it is for
Calendar and Contacts calendars and address books synced via CalDAV/CardDAV
Memories browsing photos by date and place
Notes simple Markdown notes, with a mobile app
Deck card boards for task lists
Two-Factor TOTP second authentication factor

Unofficial apps should be judged by how often they are updated: an abandoned app can stop you from moving to the next server version.

Updates without surprises

Nextcloud does not let you skip major versions: to go from 27 to 29 you must first install 28. Ignoring this rule is the most common cause of stuck installations. Before every major update it is wise to:

  • back up the database and the config folder;
  • check that the installed apps are compatible with the new version;
  • wait for a few bug-fix releases instead of updating on release day.

The occ command-line tool lets you handle maintenance, file scans and updates without the browser, and it is indispensable when something goes wrong. Commands such as occ maintenance:mode --on and occ files:scan --all are worth keeping at hand.

Common mistakes to avoid

  • Copying files straight into the data folder. Nextcloud keeps an index in the database: files added from disk do not appear until a scan is run. It is better to upload them through a client or configure a folder as "external storage".
  • Using Nextcloud as your only backup. It is a sync system: if a file is deleted or encrypted by malware on a PC, the change propagates. The trash bin and versions help, but they do not replace a separate copy.
  • Exposing it to the Internet without a second factor. It is a frequent target of automated login attempts. Two-factor authentication and the built-in brute-force protection should be enabled right away.

In short

  • Nextcloud needs a real database, Redis and system cron: without them it will be slow and unstable.
  • All-in-One is the easiest starting point; a manual setup offers more control.
  • The warnings in the admin panel point to real problems and should all be fixed.
  • Major versions are upgraded one at a time, after a backup.
  • Syncing is not a backup: you always need an independent copy.
MM
Marco Marzaduri

Marco Marzaduri works in cybersecurity, digital forensics and web development. A computer science graduate, he combines rigorous technical analysis with attention to the people who use technology.

Read also