Nextcloud 21 Upgrade: Cannot write into "config" directory!

I was running a Apache Server with Nextcloud on a Manjaro (Arch Linux) distribution. The latest upgrade to Nextcloud 21 introduced major changes such as implementing php v8 and a new user “nextcloud” to run the app.

After the upgrade I get an error on the server page: Cannot write into “config” directory! This is the first time I have encountered this after an upgrade.

Obviously I made sure the new nextcloud user is the owner of both the config directory the data directory and the writeable apps directory as the Arch Wiki page suggests.

A few things I found out:

  • config.php has permissions 644. If I change that to something more lenient, e.g. 777, I get additional errors (Cannot write into “apps” and data directory)
  • occ commands terminate with PHP Fatal error: Allowed memory size exhausted in /usr/share/webapps/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php on line 133. If I allow an unlimited amount of memory, the process gets killed after a few seconds.
  • Setting 'installed' => false in the config.php changes the occ behavior to output Nextcloud is not installed … but only if I use the binary in /usr/bin/. If I use the occ binary inside the directory ./occ the output is again Cannot write into “config” directory! in the command line.

I am by no means an expert in this and I ran out of ideas. Any suggestions on how to proceed would be much appreciated!

Some suggested information:

Nextcloud version: 21.0.0-7
Operating system and version: Manjaro 20.2.1 Nibia
Apache: 2.4.46-3
PHP version:8.0.2

The output of your config.php file:

<?php
$CONFIG = array (
'logfile' => '/var/log/nextcloud/nextcloud.log',
'apps_paths' => [
  [
    'path'=> '/usr/share/webapps/nextcloud/apps',
    'url' => '/apps',
    'writable' => false,
  ],
  [
    'path'=> '/var/lib/nextcloud/apps',
    'url' => '/wapps',
    'writable' => true,
  ],
],

  'dbtype' => 'mysql',
  'htaccess.RewriteBase' => '/nextcloud',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => '0',
);

The output of your Apache/nginx/system log in /var/log/____:

[Wed Mar 03 13:55:59.207602 2021] [ssl:warn] [pid 441] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
PHP Warning:  Version warning: Imagick was compiled against ImageMagick version 1802 but version 1803 is loaded. Imagick will run but may behave surprisingly in Unknown on line 0
[Wed Mar 03 13:55:59.228167 2021] [mpm_prefork:notice] [pid 441] AH00163: Apache/2.4.46 (Unix) OpenSSL/1.1.1j PHP/8.0.2 configured -- resuming normal operations

I could not find significant information in the Nextcloud logs.

1 Like

Hi !
Welcome in Nextcloud community !!

Have you tried : chown -R www-data:www-data config.php ?

It is possible to have the Nextcloud logs ?
Thank you !

1 Like

Hi! Thanks for your friendly message :slight_smile:

I have tried this (the user name is http on Arch), but this again raises errors:

  • Cannot write into “config” directory
  • Cannot write into “apps” directory
  • Your data directory is not writable

Here are the Logs. Please note that everything was working correctly until Mar 2 08:50 when I made the upgrade. When I couldn’t fix it immediately, I more intensively worked on finding a solution to the problem from Mar 3 13:00. I only removed ip addresses from the logs. The apache daemon binary is called httpd.

Thanks so much for trying to help!

1 Like

These are not the right logs :slight_smile:
The file should be in data/nextcloud.log.

Okay here is the log you were asking for: nextcloud_crop.log - Pastebin.com

I only pasted 1 line before the update, then the 9 first lines after the update and then the 10 last lines of the log. I did this because the file size was quite large (1.9MB) and I could not put this much to pastebin. In total there were 585 lines after the update. Interestingly, there was almost no logging going on most of the time.

I hope this helps!

Hi !

Thank you for the logs !

During the update, there was an error with the following applications:

  • settings
  • calendar
  • dashboard
  • photos
  • tasks
Message":"Unable to generate a URL for the named route \"settings.Help.help\" as such route does not exist.","Code":0,"Trace":

Have you tried : occ upgrade ?
What if you move the folder above (in /nextcloud/apps/…) to another directory (is to deactivate them) ?

There are IPs in your file. :slight_smile:

Thanks a lot for looking at the logs!

First I move the individual folders you suggested to somewhere else. Nothing changed. Then I moved all folders from nextcloud/apps/* to somewhere else. Again, same result.

occ upgrade says PHP Fatal error: Allowed memory size […] exhausted […] in […]nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php on line 133

The only thing I can come up with at this points is to completely remove everything, reinstall nextcloud, restore a backup of the database and hope that it then somehow works.

Hi !

Do you use php-fpm ?
If you use it, maybe it can help you :

systemctl edit php-fpm.service and add :

[Service]
ReadWritePaths = /mnt/euler/nextcloud/data/
ReadWritePaths = /usr/share/webapps/nextcloud/apps
ReadWritePaths = /etc/webapps/nextcloud/config/

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

Yes, unfortunately. I don’t have another idea but if you need help we are here !!

1 Like

TL;DR: All relevant directories need write permissions for both the new user “nextcloud” and the user “http”.

So I installed Manjaro from scratch, configured a LAMP server, which is working, installed the Nextcloud package and …

Internal Server Error

but at least the php memory errors didn’t show up anymore.

However just by pure coincidence I found out about a setup which works. The introduction of the new “nextcloud” user has left a kind of weird situation where both the http user and the nextcloud user need to have write access to the relevant directories.

E.g. the config directories permissions are correct when user=nextcloud group=http and permissions are 775. The config.php on the other hand works with 660. Here’s the catch: Nextcloud overwrites the file’s permissions back to 640 when maintenance mode is turned on for example. The other directories apps, and data also need wirte permissions both for nextcloud and http user.

Thanks a lot @didi44 for your really kind words and the support!

2 Likes

didi44:

Wow, THANK YOU! After much frustration, your solution was priceless.

1 Like

i’m getting the same error.

  • please clarify a bit on your solution. did you make new users as “nextcloud” and “http” ?
  • if so, which one did you use for the config directory and the config file?

i’m constantly getting this config write error for every few minutes (gone and back). www-data:www-data user doesn’t seems to work.

EDIT: my bad. i was running 2 docker containers that ran the same server (backup), causing conflicts and weird things. took me 2 days to figure it out.

I have nextcloud running on ubuntu 20.04 I am getting this error when running occ commands. How do I change the config folder permissions via ssh. Sorry this seems like a noob question but I am new to the linux world.

Hi @Hemi !

This is not a stupid question :slight_smile:

Did you try to run sudo chown -R www-data:www-data /your/nextcloud_path

1 Like

I know i’m late but this works for me

sudo chmod 777 -R /path/to/config

Thank you didi44, I ran this and it fix my upgrade issue.