Nextcloud
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.[1]
This guide is about installing the web server components of nextcloud. It contains no instructions on installing the (optional) desktop client.
Requirements
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.
PHP
Before (re-)emerging PHP in order to get supported modules, see upstream's list of supported PHP versions and associated modules[2] 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:
user $
php -m | grep -i 'pdo_pgsql'
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.
Caching
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
root #
emerge --ask dev-php/pecl-memcached
memcached package must also be installed:
root #
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.
root #
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:
root #
certbot --nginx --rsa-key-size 4096 --staple-ocsp --hsts
Installation
Once PHP, Apache and (optionally) the caching service have been installed, simply set the USE flags for nextcloud and emerge the service.
USE flags
USE flags for www-apps/nextcloud Personal cloud that runs on your own server
curl
|
Add support for client-side URL transfer library |
imagemagick
|
Enable optional support for the ImageMagick or GraphicsMagick image converter |
mysql
|
Add mySQL Database support |
postgres
|
Add support for the postgresql database |
sqlite
|
Add support for sqlite - embedded sql database |
vhosts
|
Add support for installing web-based applications into a virtual-hosting environment |
Emerge
root #
emerge --ask www-apps/nextcloud
The following command is a recommendation for webapp-config:
root #
webapp-config -h /nextcloud -d / -I 26.0.0
Configuration
Files
/var/www/nextcloud/htdocs - Contains the nextcloud files if the install was performed using the recommended method.
Service
OpenRC
On an OpenRC system Nextcloud does not have a specific service, but runs on services from the LAMP stack:
root #
rc-update add postgresql-15 default
root #
rc-update add apache2 default