NC 22 after reboot - Cannot write into "config" directory!

Nextcloud version: 22.2.3.0
Operating system and version: Arch Linux 5.10.90-1-lts x86_64
Apache or nginx version: nginx/1.20.2
PHP version: 8.0.14

The issue you are facing: After restart of the server, Nextcloud web displays error “Cannot write into “config” directory!

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Update of the server (pacman -Syu)
  2. reboot
  3. visit NC website

The output of your Nextcloud log in Admin > Logging: https://pastebin.com/CawtW71D

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'config_is_read_only' => false,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/run/redis/redis.sock',
    'port' => 0,
  ),
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/usr/share/nginx/html/nextcloud/apps',
      'url' => '/apps',
      'writable' => true,
    ),
    1 => 
    array (
      'path' => '/usr/share/nginx/html/nextcloud/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'instanceid' => 'INSTANCEID',
  'passwordsalt' => 'REDACTED',
  'secret' => 'REDACTED',
  'trusted_domains' => 
  array (
    0 => 'nextcloud.MYDOMAIN.cz',
  ),
  'datadirectory' => '/home/tyler/nex/data/',
  'dbtype' => 'mysql',
  'version' => '22.2.3.0',
  'overwrite.cli.url' => 'http://nextcloud.MYDOMAIN.cz',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => '',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'REDACTED',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'MYDOMAIN',
  'mail_domain' => 'MYDOMAIN.cz',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'mail.MYDOMAIN.cz',
  'mail_smtpname' => 'tyler@MYDOMAIN.cz',
  'mail_smtppassword' => 'REDACTED',
  'mail_smtpsecure' => 'ssl',
  'mail_smtpport' => '465',
  'twofactor_enforced' => 'true',
  'twofactor_enforced_groups' => 
  array (
  ),
  'twofactor_enforced_excluded_groups' => 
  array (
  ),
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 3,
  'app_install_overwrite' => 
  array (
    0 => 'drawio',
  ),
  'data-fingerprint' => '2099a474defcf5c8a215790505997d93',
  'default_phone_region' => '+420',
  'has_rebuilt_cache' => true,
);

Nginx and php-fpm are running under http user.
Permissions of the files/dirs should be ok:

ll /usr/share/nginx/html/nextcloud/
total 168
drwxrwx--- 14 http http  4096 Jan 10 12:52 .
drwxr-xr-x  6 root root  4096 Jan  9 12:03 ..
drwxrwx--- 44 http http  4096 Nov 16 13:52 3rdparty
drwxrwx--- 48 http http  4096 Nov 16 13:52 apps
-rwxrwx---  1 http http 19327 Nov 16 13:52 AUTHORS
drwxrwx---  2 http http  4096 Jan 11 09:37 config
-rwxrwx---  1 http http  3924 Nov 16 13:52 console.php
-rwxrwx---  1 http http 34520 Nov 16 13:52 COPYING
drwxrwx--- 22 http http  4096 Nov 16 13:52 core
-rwxrwx---  1 http http  5163 Nov 16 13:52 cron.php
drwxrwx--- 35 http http  4096 Dec 17 15:24 custom_apps
-rwxrwx---  1 http http  3252 Nov 16 17:51 .htaccess
-rwxrwx---  1 http http   156 Nov 16 13:52 index.html
-rwxrwx---  1 http http  3504 Jan 10 12:52 index.php
drwxrwx---  6 http http  4096 Nov 16 13:52 lib
-rwxrwx---  1 http http   283 Nov 16 13:52 occ
drwxrwx---  2 http http  4096 Nov 16 13:52 ocm-provider
drwxrwx---  2 http http  4096 Nov 16 13:52 ocs
drwxrwx---  2 http http  4096 Nov 16 13:52 ocs-provider
-rwxrwx---  1 http http  3139 Nov 16 13:52 public.php
-rwxrwx---  1 http http  5340 Nov 16 13:52 remote.php
drwxrwx---  4 http http  4096 Nov 16 13:52 resources
-rwxrwx---  1 http http    26 Nov 16 13:52 robots.txt
-rwxrwx---  1 http http  2452 Nov 16 13:52 status.php
drwxrwx---  3 http http  4096 Nov 16 13:52 themes
drwxrwx---  2 http http  4096 Sep 29 23:19 updater
-rwxrwx---  1 http http   101 Nov 16 13:52 .user.ini
-rwxrwx---  1 http http   422 Nov 16 13:52 version.php
# ll /usr/share/nginx/html/nextcloud/config/
total 104
drwxrwx---  2 http http  4096 Jan 11 09:37 .
drwxrwx--- 14 http http  4096 Jan 10 12:52 ..
-rwxrwx---  1 http http    76 Oct 16 10:32 apcu.config.php
-rwxrwx---  1 http http   377 Oct 16 11:57 apps.config.php
-rwxrwx---  1 http http  2028 Jan 11 09:37 config.php
-rwxrwx---  1 http http 61785 Nov 16 13:52 config.sample.php
-rwxrwx---  1 http http   495 Nov 16 13:52 .htaccess
-rwxrwx---  1 http http    35 Feb 13  2020 mimetypealiases.json
-rwxrwx---  1 http http    46 Feb 13  2020 mimetypemapping.json
-rwxrwx---  1 http http   300 Oct 14 19:13 redis.config.php
-rwxrwx---  1 http http   669 Jun 14  2019 smtp.config.php
ll /home/tyler/nex/data/
total 20609100
drwxrwx--- 15 http http        4096 Dec 10 11:14 .
drwxrwx---  3 http http        4096 Oct 15 19:59 ..
drwxrwx--- 13 http http        4096 Jan 29  2021 appdata_INSTANCEID
-rwxrwx---  1 http http           0 Oct 20 09:52 audit.log
drwxrwx---  3 http http        4096 Nov  8 22:16 files_encryption
drwxrwx---  2 http http        4096 Jan 17  2021 files_external
-rwxrwx---  1 http http           0 Oct 16 16:50 flow.log
drwxrwx---  2 http http        4096 Sep  1  2019 gpxpod
drwxrwx---  2 http http        4096 Feb 13  2020 __groupfolders
-rwxrwx---  1 http http         542 Nov 16 17:51 .htaccess
-rwxrwx---  1 http http           0 Nov 16 17:51 index.html
-rw-r-----  1 http http    63065202 Jan 10 12:52 nextcloud.log
-rwxrwx---  1 http http 21040507047 Oct  7 21:32 nextcloud.log.1
-rwxrwx---  1 http http           0 Nov 16 17:51 .ocdata
drwxrwx--- 15 http http        4096 May 13  2021 ownbackup
-rwxrwx---  1 http http        4096 Oct  7 21:10 owncloud.db
drwxrwx---  8 http http        4096 Nov  9 00:10 tyler
drwxrwx---  3 http http        4096 Jul 25 11:46 test
-rwxrwx---  1 http http       33994 Nov 16 17:51 updater.log
drwxrwx---  4 http http        4096 Nov 16 17:51 updater-ocwrmpj8dvw6
root@server:/usr/share/nginx/html/nextcloud# su http
[http@server nextcloud]$ echo test > config/test.txt
[http@server nextcloud]$ cat config/test.txt 
test
[http@server nextcloud]$ rm config/test.txt 
[http@server nextcloud]$ ls -al config/
total 104
drwxrwx---  2 http http  4096 Jan 11 10:54 .
drwxrwx--- 14 http http  4096 Jan 10 12:52 ..
-rwxrwx---  1 http http    76 Oct 16 10:32 apcu.config.php
-rwxrwx---  1 http http   377 Oct 16 11:57 apps.config.php
-rwxrwx---  1 http http  2028 Jan 11 09:37 config.php
-rwxrwx---  1 http http 61785 Nov 16 13:52 config.sample.php
-rwxrwx---  1 http http   495 Nov 16 13:52 .htaccess
-rwxrwx---  1 http http    35 Feb 13  2020 mimetypealiases.json
-rwxrwx---  1 http http    46 Feb 13  2020 mimetypemapping.json
-rwxrwx---  1 http http   300 Oct 14 19:13 redis.config.php
-rwxrwx---  1 http http   669 Jun 14  2019 smtp.config.php

If I put config_is_read_only’ => true to the config.php I get Cannot write into “apps” directory
I tried (I guess) all the solutions from this forum and nothing helped.

Thanks for your suggestions, I am out of ideas:)

Ok, I found solution right after posting:)
I put to the /usr/lib/systemd/system/php-fpm.service

ReadWritePaths = /home/tyler/nex
ReadWritePaths = /usr/share/nginx/html

then

# systemctl daemon-reload
# systemctl restart php-fpm.service

and it works now.

Based on:
Cannot write into "config" directory after upgrade - #2 by quiwy