Nextcloud is a free and open source cloud hub primarily intended for file synchronization and sharing. It features a rich ecosystem of different apps .
This installation document was written with Nextcloud 26 as a target and attempts to provide a fast installation on Gentoo systems.
This guide is about installing the web server components of nextcloud. It contains no instructions on installing the (optional) desktop client.
Nextcloud requires software components from the standard (L)AMP stack: a web server, a database, and PHP (php-fpm). Apache and Nginx are supported web servers.
Before (re-)emerging PHP in order to get supported modules, see upstream's list of supported PHP versions and associated modules which are necessary for correct operation of Nextcloud.
These USE flags for dev-lang/php are required in order for Nextcloud to function correctly: ctype curl fileinfo filter gd iconv json ssl posix session simplexml xmlreader xmlwriter zip zlib
Please choose one of PostgreSQL, MySQL/MariaDB or sqlite (discouraged). This tutorial will use PostgreSQL (recommended) as the database, thus adding the USE flag postgres. MySQL would use mysql while sqlite would employ sqlite.
Verify one of three possible modules exist for the database connector. In this instance, PostgreSQL will be the application's database:
php -m | grep -i 'pdo_pgsql'
Generally recommended USE flags are bz2 gmp bcmath exif intl sysvipc. After installing or uninstalling any php modules, the web server, and/or php-fpm depending on the configuration, needs to be restarted.
Recommended for enhanced server performance is to pair Nextcloud with memcached or others. This PHP module is a PECL extension and is installed separately from php itself. On Gentoo, the php module is available in the following package
emerge --ask dev-php/pecl-memcached
memcached package must also be installed:
emerge --ask net-misc/memcached
Verify the module is available to PHP.
Signed SSL certificate (Let's Encrypt)
Let's Encrypt can be used to obtain free certificates which have been signed by a recognized signing authority.
certbot --apache --rsa-key-size 4096 --staple-ocsp --hsts
Simply choose a desired domain and request the certificate.
For nginx, simply use this command instead:
certbot --nginx --rsa-key-size 4096 --staple-ocsp --hsts
Once PHP, Apache and (optionally) the caching service have been installed, simply set the USE flags for nextcloud and emerge the service.
USE flags for www-apps/nextcloud Personal cloud that runs on your own server
||Add support for client-side URL transfer library|
||Enable optional support for the ImageMagick or GraphicsMagick image converter|
||Add mySQL Database support|
||Add support for the postgresql database|
||Add support for sqlite - embedded sql database|
||Add support for installing web-based applications into a virtual-hosting environment|
emerge --ask www-apps/nextcloud
The following command is a recommendation for webapp-config:
webapp-config -h /nextcloud -d / -I 26.0.0
/var/www/nextcloud/htdocs - Contains the nextcloud files if the install was performed using the recommended method.
On an OpenRC system Nextcloud does not have a specific service, but runs on services from the LAMP stack:
rc-update add postgresql-15 default
rc-update add apache2 default