Nextcloud delivered by Ansible

Self-hosted, entirely open-source collaboration solution setup in under 5 minutes.

By Kostas Koutsogiannopoulos


Nextcloud server setup can be a little tricky depending on the stack that you will choose. It heavily depends on linux system libraries, it needs a web server with special configuration (not just a reverse proxy) to work with and PHP-FPM as the process manager for the php apps. It needs a caching solution for optimum performance. It also needs a relational database and a file system for the data.

We needed to streamline the set up procedure for our customers in order to be as declarative as possible for administrative and security reasons.

Ansible turned out to be the right tool for the job. We wrote a single playbook that you can run against a private server, public site, virtual machine etc.

Τhe stack was chosen based on simplicity, security and the experience of trouble-free operation over time as always.

Our stack of choice


OSAlmalinux 9Latest release
DatabasePosgreSQL 13Official almalinux repositories
Web serverNginx 1.20Official almalinux repositories
Cache / session managementRedis 6.2.6Official almalinux repositories
RuntimePHP 8.0Official almalinux repositories
ApplicationNextcloud 24Latest stable release


  • We did not deal with TLS in the current setup. We are leaving this on customer's team because it is based on their own specific infrastructure. The procedure will deliver only a http service that is listening on a customizable port.
  • We are using only almalinux official repositories and epel for some PHP modules.
  • We did not make any nextcloud configuration via ansible. You can do this from application's UI or editing config.php after the setup. This includes database connection string, filesystem path for the data, memcache configuration, initial administrator account, ldap integration etc.
  • The nginx configuration is the same that is currently recommended by documentation for customizable subdir of nginx's webroot:
  • We tried to give every task, self-explanatory names. You can find the playbook along with the templates on this gitlab repository.

The playbook

For a current version of our playbook you can visit our repository here:

For a quick clone:

git clone

Feel free to open any issue, suggestion or anything you find useful.

View epilis's profile on LinkedIn Visit us on facebook X epilis rss feed: Latest articles