Cannot write into directories

Nextcloud version (eg, 20.0.5): 22.2.0
Operating system and version (eg, Ubuntu 20.04): AlmaLinux 8.5 (it is simular to centos8)
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.37
PHP version (eg, 7.4): 7.4.26

The issue you are facing:

After migrating my nextcloud over to a AlmaLinux dedicated server. I have run into these issues:

  • It was not possible to execute the cron job via CLI. The following technical errors have appeared:
    • Cannot write into “apps” directory This can usually be fixed by giving the webserver write access to the apps directory or disabling the App Store in the config file.
    • Your data directory is not writable Permissions can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/22/go.php?to=admin-dir_permissions.

I have even gone as far as putting SELinux into passive mode even after following all the steps in SELinux Configuration documentation. So, it looks like this isn’t the issue.

Here is a screenshot of my filesystem for nextcloud. It is installed in var/www/nextcloud
RYMCVsvYJySGVp5BP4I

If anybody has any ideas on what could be causing this issue. Please let me know. Thanks for your help!

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

Steps to replicate it:

  1. Move over NextCloud installation from an ubuntu 20.04 installation.
  2. ^ Follow the steps specified in the documentation regarding server migration

The output of your Nextcloud log in Admin > Logging:

The file was too big, so please download the file here.

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

<?php
$CONFIG = array (
  'instanceid' => 'oc28gnlck4ux',
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'trusted_domains' => 
  array (
    0 => 'xx',
    1 => 'xx',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '22.2.0.2',
  'overwrite.cli.url' => 'xx',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'xxx',
  'installed' => true,
  'htaccess.RewriteBase' => '/',
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'noreply',
  'mail_domain' => 'xxx',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'xxx',
  'mail_smtpport' => '25',
  'mail_smtpname' => 'xxx',
  'mail_smtppassword' => 'xxx',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'default_phone_region' => 'GB',
  'updater.secret' => 'xxx',
);

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

[Wed Dec 08 18:42:52.282217 2021] [mpm_event:notice] [pid 117744:tid 140109682612544] AH00492: caught SIGWINCH, shutting down gracefully
[Wed Dec 08 18:42:54.242273 2021] [core:notice] [pid 129760:tid 140332808526144] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Wed Dec 08 18:42:54.243338 2021] [suexec:notice] [pid 129760:tid 140332808526144] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Dec 08 18:42:54.251269 2021] [so:warn] [pid 129760] AH01574: module rewrite_module is already loaded, skipping
[Wed Dec 08 18:42:54.843648 2021] [lbmethod_heartbeat:notice] [pid 129760:tid 140332808526144] AH02282: No slotmem from mod_heartmonitor
[Wed Dec 08 18:42:54.846329 2021] [mpm_event:notice] [pid 129760:tid 140332808526144] AH00489: Apache/2.4.37 (AlmaLinux) OpenSSL/1.1.1k configured -- resuming normal operations
[Wed Dec 08 18:42:54.846357 2021] [core:notice] [pid 129760:tid 140332808526144] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Wed Dec 08 18:44:27.205128 2021] [mpm_event:notice] [pid 129760:tid 140332808526144] AH00492: caught SIGWINCH, shutting down gracefully
[Wed Dec 08 18:44:28.306436 2021] [core:notice] [pid 133867:tid 140433922509120] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Wed Dec 08 18:44:28.307491 2021] [suexec:notice] [pid 133867:tid 140433922509120] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Dec 08 18:44:28.314926 2021] [so:warn] [pid 133867] AH01574: module rewrite_module is already loaded, skipping
[Wed Dec 08 18:44:29.241406 2021] [lbmethod_heartbeat:notice] [pid 133867:tid 140433922509120] AH02282: No slotmem from mod_heartmonitor
[Wed Dec 08 18:44:29.243986 2021] [mpm_event:notice] [pid 133867:tid 140433922509120] AH00489: Apache/2.4.37 (AlmaLinux) OpenSSL/1.1.1k configured -- resuming normal operations
[Wed Dec 08 18:44:29.244010 2021] [core:notice] [pid 133867:tid 140433922509120] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Wed Dec 08 18:46:22.458674 2021] [mpm_event:notice] [pid 133867:tid 140433922509120] AH00492: caught SIGWINCH, shutting down gracefully
[Wed Dec 08 18:46:28.607795 2021] [core:notice] [pid 138764:tid 139687419722048] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Wed Dec 08 18:46:28.608909 2021] [suexec:notice] [pid 138764:tid 139687419722048] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Dec 08 18:46:28.616712 2021] [so:warn] [pid 138764] AH01574: module rewrite_module is already loaded, skipping
[Wed Dec 08 18:46:28.648164 2021] [lbmethod_heartbeat:notice] [pid 138764:tid 139687419722048] AH02282: No slotmem from mod_heartmonitor
[Wed Dec 08 18:46:28.650685 2021] [mpm_event:notice] [pid 138764:tid 139687419722048] AH00489: Apache/2.4.37 (AlmaLinux) OpenSSL/1.1.1k configured -- resuming normal operations
[Wed Dec 08 18:46:28.650712 2021] [core:notice] [pid 138764:tid 139687419722048] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Wed Dec 08 18:48:22.768974 2021] [mpm_event:notice] [pid 138764:tid 139687419722048] AH00492: caught SIGWINCH, shutting down gracefully
[Wed Dec 08 18:48:24.371548 2021] [core:notice] [pid 143565:tid 140017973324096] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Wed Dec 08 18:48:24.372605 2021] [suexec:notice] [pid 143565:tid 140017973324096] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Dec 08 18:48:24.380269 2021] [so:warn] [pid 143565] AH01574: module rewrite_module is already loaded, skipping
[Wed Dec 08 18:48:24.410461 2021] [lbmethod_heartbeat:notice] [pid 143565:tid 140017973324096] AH02282: No slotmem from mod_heartmonitor
[Wed Dec 08 18:48:24.412990 2021] [mpm_event:notice] [pid 143565:tid 140017973324096] AH00489: Apache/2.4.37 (AlmaLinux) OpenSSL/1.1.1k configured -- resuming normal operations
[Wed Dec 08 18:48:24.413016 2021] [core:notice] [pid 143565:tid 140017973324096] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Wed Dec 08 18:48:53.178282 2021] [proxy_fcgi:error] [pid 143569:tid 140017328490240] [client 45.85.194.152:56982] AH01067: Failed to read FastCGI header
[Wed Dec 08 18:48:53.178539 2021] [proxy_fcgi:error] [pid 143569:tid 140017328490240] (104)Connection reset by peer: [client 45.85.194.152:56982] AH01075: Error dispatching request to :
[Wed Dec 08 18:48:53.180198 2021] [proxy_fcgi:error] [pid 143569:tid 140016772691712] [client 45.85.194.152:57011] AH01067: Failed to read FastCGI header
[Wed Dec 08 18:48:53.180194 2021] [proxy_fcgi:error] [pid 143568:tid 140016638473984] [client 45.85.194.152:57007] AH01067: Failed to read FastCGI header
[Wed Dec 08 18:48:53.180219 2021] [proxy_fcgi:error] [pid 143569:tid 140016772691712] (104)Connection reset by peer: [client 45.85.194.152:57011] AH01075: Error dispatching request to :
[Wed Dec 08 18:48:53.180225 2021] [proxy_fcgi:error] [pid 143568:tid 140016638473984] (104)Connection reset by peer: [client 45.85.194.152:57007] AH01075: Error dispatching request to :
[Wed Dec 08 18:51:19.554898 2021] [proxy_fcgi:error] [pid 143781:tid 140017286526720] [client 45.85.194.152:57223] AH01067: Failed to read FastCGI header
[Wed Dec 08 18:51:19.554927 2021] [proxy_fcgi:error] [pid 143781:tid 140017286526720] (104)Connection reset by peer: [client 45.85.194.152:57223] AH01075: Error dispatching request to :
[Wed Dec 08 18:51:27.001395 2021] [proxy_fcgi:error] [pid 143569:tid 140016109995776] [client 45.85.194.152:57244] AH01067: Failed to read FastCGI header
[Wed Dec 08 18:51:27.001423 2021] [proxy_fcgi:error] [pid 143569:tid 140016109995776] (104)Connection reset by peer: [client 45.85.194.152:57244] AH01075: Error dispatching request to :
[Wed Dec 08 18:51:52.397162 2021] [access_compat:error] [pid 143568:tid 140016764299008] [client 45.85.194.152:57294] AH01797: client denied by server configuration: /var/www/nextcloud/data/.ocdata
[Wed Dec 08 18:53:46.746114 2021] [access_compat:error] [pid 143781:tid 140016126781184] [client 45.85.194.152:57464] AH01797: client denied by server configuration: /var/www/nextcloud/data/.ocdata
[Wed Dec 08 18:56:36.874165 2021] [access_compat:error] [pid 143568:tid 140016630081280] [client 45.85.194.152:57666] AH01797: client denied by server configuration: /var/www/nextcloud/data/.ocdata
[Wed Dec 08 18:57:31.499933 2021] [access_compat:error] [pid 143567:tid 140017099646720] [client 45.85.194.152:57733] AH01797: client denied by server configuration: /var/www/nextcloud/data/.ocdata
[Wed Dec 08 18:58:17.412162 2021] [access_compat:error] [pid 143781:tid 140017320097536] [client 45.85.194.152:57802] AH01797: client denied by server configuration: /var/www/nextcloud/data/.ocdata
[Wed Dec 08 19:00:02.268937 2021] [access_compat:error] [pid 143569:tid 140017320097536] [client 45.85.194.152:57940] AH01797: client denied by server configuration: /var/www/nextcloud/data/.ocdata
[Wed Dec 08 19:00:19.777866 2021] [access_compat:error] [pid 143569:tid 140016219035392] [client 45.85.194.152:57965] AH01797: client denied by server configuration: /var/www/nextcloud/data/.ocdata
[Wed Dec 08 19:01:01.566465 2021] [access_compat:error] [pid 143569:tid 140016781084416] [client 45.85.194.152:58017] AH01797: client denied by server configuration: /var/www/nextcloud/data/.ocdata
[Wed Dec 08 19:07:15.273354 2021] [access_compat:error] [pid 143569:tid 140016135173888] [client 45.85.194.152:58517] AH01797: client denied by server configuration: /var/www/nextcloud/data/.ocdata
[Wed Dec 08 19:08:11.742064 2021] [access_compat:error] [pid 143567:tid 140016185497344] [client 45.85.194.152:58592] AH01797: client denied by server configuration: /var/www/nextcloud/data/.ocdata
[Wed Dec 08 19:09:19.426452 2021] [mpm_event:notice] [pid 143565:tid 140017973324096] AH00492: caught SIGWINCH, shutting down gracefully
[Wed Dec 08 19:09:21.515732 2021] [core:notice] [pid 2592133:tid 140068040350016] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Wed Dec 08 19:09:21.516852 2021] [suexec:notice] [pid 2592133:tid 140068040350016] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Dec 08 19:09:21.524918 2021] [so:warn] [pid 2592133] AH01574: module rewrite_module is already loaded, skipping
[Wed Dec 08 19:09:26.583760 2021] [lbmethod_heartbeat:notice] [pid 2592133:tid 140068040350016] AH02282: No slotmem from mod_heartmonitor
[Wed Dec 08 19:09:26.586616 2021] [mpm_event:notice] [pid 2592133:tid 140068040350016] AH00489: Apache/2.4.37 (AlmaLinux) OpenSSL/1.1.1k configured -- resuming normal operations

r u sure that apache:apache is your dedicated owner for NC?

I’m unsure. I just assumed so since it says that in the docs. Where can I check this?

yopur nextcloud-directory is owned by?

It’s owned by apache:apache as shown in the screenshot.

1 Like

What is the output of

ls -al /var/spool/cron/crontabs

ls: cannot access '/var/spool/cron/crontabs': No such file or directory

Sorry i overlooked that you are using AlmaLinux.

No worries, yes that’s correct. It is simular to centos8.

How does your cron job looks like?

Which path is in “datadirectory=” of your config.php?

BTW: I have disabled SELinux on my server.

I’ve put SELinux into passive mode for the time being.

'datadirectory' => '/var/www/nextcloud/data',

I’m not actually sure if I’ve setup a corn job yet on this server. It didn’t say to in the migration guide. Is this something I should’ve done? If so, how?

Thanks!

Maybe a dumb question, but is there actually a cronjob set in the crontab of the apache user? Whats the output of: crontab -u apache -l

Aha! There is not. It didn’t say to in the documentation so I must’ve glazed over it. How should I add one?

crontab -u apache -e

-u apache for the user and -e for edit.

Great! What do I put for the task?

It should be well described in the installation manual of Nextcloud.

*/5 * * * * php -f /path/to/nextcloud/cron.php

https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/background_jobs_configuration.html

Thank you very much.

However. I am still getting a few errors:

* It was not possible to execute the cron job via CLI. The following technical errors have appeared:
  * Cannot write into "apps" directory This can usually be fixed by giving the webserver write access to the apps directory or disabling the App Store in the config file.
  * Your data directory is not writable Permissions can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/22/go.php?to=admin-dir_permissions.

* This server has no working Internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the Internet to enjoy all features.

Is there a way to check what “account” nextcloud is attempting to use? Because I’m sure that the user/group apache:apache has access since it owns it.

That warning has now gone away.