From Gentoo Wiki
Jump to:navigation Jump to:search

A place where I keep some infrastructure tips.


Fixing memory issue

From the commandline, first check for proper dependencies:

user $sudo -u nginx php /var/www/ check
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see
The current PHP memory limit is below the recommended value of 512MB.
Nextcloud is not installed - only a limited number of commands are available

In this instance, the current PHP memory limited is advised to be adjusted up, so make the correction for the currently selected PHP implementation:

root #eselect php list fpm
  [1]   php7.3
  [2]   php7.4
  [3]   php8.0 *
FILE /etc/php/cli-php8.0/php.ini
; Maximum amount of memory a script may consume
; memory_limit = 128M
memory_limit = 1024M

Restart PHP and then rerun the check above to verify the memory limit has been resolved.

root #rc-service php-fpm restart

Running the installer

Run the installer from the commandline:

user $sudo -u nginx php /var/www/ maintenance:install
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see
What is the password you like to use for the admin account <admin>?
Nextcloud was successfully installed

Connecting to Nextcloud

Before connecting via HTTP on any host other than localhost, the trusted domain will need to be configured. This is located in the Nextcloud installation directory, followed by config/config.php. Edit the file to add additional trusted domains or IP addresses to the array of values.

FILE config/config.php
array (
    0 => 'localhost',
    1 => '',
    2 => '192.168.0.*',

Modifying the production database location

Depending on the amount of users, a production database may grow quite large. By default, MySQL stories creates its data directory under the var/lib/mysql directory. This directory may be modified via the datadir variable in the /etc/mysql/mysql.d/50-distro-server.cnf file. Unless the var/lib/mysql is large enough to hold the database, consider modifying the the datadir path to a suitable location.

Configuring a production database

My default Nextcloud will use an SQLite database. While this database implementation may be good for single user testing purposes, it is not good if the system will be used in any level of production.[1] MySQL will be the database used in this guide.

Install the dev-db/mysql package:

root #emerge --ask dev-db/mysql

Add SQL to the default runlevel (OpenRC):

root #rc-update add mysql default

Configure a new SQL database. Follow the prompts as necessary. Be sure to record the root user's password in a place where it will not be lost.

root #emerge --config dev-db/mysql

Start the SQL server:

root #rc-service mysql start

Configure PHP to use MySQL

Upstream's guide[2]


root #mysql -u root -p -h localhost
Enter password:

Fill in the following as necessary, substituting username with a new username and password with a strong, random passwords. As stated above, be sure to record this information in a secure place.

mysql>CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
mysql>CREATE DATABASE IF NOT EXISTS nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
mysql>GRANT ALL PRIVILEGES on nextcloud.* to 'username'@'localhost';
mysql>FLUSH privileges;

Then, from the web root, run:

root #sudo -u nginx php occ db:convert-type --all-apps --clear-schema mysql nextcloud localhost nextcloud
What is the database password?

Clearing schema in new database
Creating schema in new database

Sadly a workaround is required for database conversion on Nextcloud 21.[4]

hief image preview support

In order for Nextcloud to include render support for hief images in the web browser, Imagemagick must support the hief file format.

FILE /etc/portage/package.use/imagemagickEnable support for image media formats in imagemagick
media-gfx/imagemagick djvu hdri heif jbig jpeg2k lcms lzma raw svg tiff webp xml