A place where I keep some infrastructure tips.
Gentoo for infrastructure
Gentoo for infrastructure? Yes, Gentoo can and should be used for infrastructure. Generally I run a badge on my sites when I indicate something is running Gentoo underneath.
Get the CLI program from the GURU ebuild repo:
emerge --ask eselect-repository
eselect repository enable guru
emaint sync --repo guru
Download and import the blockchain (optional). Download will take a while. As of Nov 10, 2021 the blockchain is just over 80 GBs and downloads on average of 2 MB/s.
Blockchain import does not appear to be working when run as a non-root user... Simpler to do a P2P download through the daemon.
Generate a wallet (if not done already).
Add the wallet to the daemon's configuration file:
# Add wallet to start-mining start-mining=
qml to global use flags for Qt:
Add the following
Problem: Attempting to run a ruby program results in strange errors
/usr/lib64/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/definition.rb:502:in `materialize': Could not find RbST-0.6.5, base32-0.3.4, nokogiri-1.12.3, kramdown-parser-gfm-1.1.0, rexml-3.2.3, jekyll-feed-0.15.1, jekyll-gist-1.5.0, jekyll-paginate-1.1.0, mini_portile2-2.6.1, racc-1.5.2, kramdown-2.3.1, jekyll-4.2.0, octokit-4.21.0, addressable-2.8.0, colorator-1.1.0, em-websocket-0.5.2, i18n-1.8.10, jekyll-sass-converter-2.1.0, jekyll-watch-2.2.1, liquid-4.0.3, mercenary-0.4.0, pathutil-0.16.2, rouge-3.26.0, safe_yaml-1.0.5, terminal-table-2.0.0, faraday-1.7.0, sawyer-0.8.2, public_suffix-4.0.6, eventmachine-1.2.7, http_parser.rb-0.6.0, concurrent-ruby-1.1.9, sassc-2.4.0, listen-3.7.0, forwardable-extended-2.6.0, unicode-display_width-1.7.0, faraday-em_http-1.0.0, faraday-em_synchrony-1.0.0, faraday-excon-1.1.0, faraday-httpclient-1.0.1, faraday-net_http-1.0.1, faraday-net_http_persistent-1.2.0, faraday-patron-1.0.0, faraday-rack-1.0.0, multipart-post-2.1.1, ruby2_keywords-0.0.5, ffi-1.15.3, rb-fsevent-0.11.0, rb-inotify-0.10.1 in any of the sources (Bundler::GemNotFound)from /usr/lib64/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/definition.rb:189:in `specs' from /usr/lib64/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/definition.rb:237:in `specs_for' from /usr/lib64/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/runtime.rb:18:in `setup' from /usr/lib64/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler.rb:150:in `setup' from /usr/lib64/ruby/gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/plugin_manager.rb:52:in `require_from_bundler' from /usr/lib64/ruby/gems/2.6.0/gems/jekyll-4.2.0/exe/jekyll:11:in `<top (required)>' from /usr/bin/jekyll:9:in `load' from /usr/bin/jekyll:9:in `<main>'
Fixing memory issue
From the commandline, first check for proper dependencies:
sudo -u nginx php /var/www/digitalsurvival.us/occ check
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see https://www.php.net/manual/en/book.pcntl.php 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:
eselect php list fpm
 php7.3  php7.4  php8.0 *
; Maximum amount of memory a script may consume ; http://php.net/memory-limit ; memory_limit = 128M memory_limit = 1024M
Restart PHP and then rerun the check above to verify the memory limit has been resolved.
rc-service php-fpm restart
Running the installer
Run the installer from the commandline:
sudo -u nginx php /var/www/digitalsurvival.us/occ maintenance:install
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see https://www.php.net/manual/en/book.pcntl.php 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.
array ( 0 => 'localhost', 1 => 'cloud.digitalsurvival.us', 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. MySQL will be the database used in this guide.
Install the dev-db/mysql package:
emerge --ask dev-db/mysql
Add SQL to the default runlevel (OpenRC):
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.
emerge --config dev-db/mysql
Start the SQL server:
rc-service mysql start
Configure PHP to use MySQL
mysql -u root -p -h localhost
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.
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE IF NOT EXISTS nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES on nextcloud.* to 'username'@'localhost';
Then, from the web root, run:
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.
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.
media-gfx/imagemagick djvu hdri heif jbig jpeg2k lcms lzma raw svg tiff webp xml