PHP chmod() Permission error

I have the nextcloud docker running in pi4 and storing it’s data in an external ntfs drive.
I have already given all permission to write and read for all the folders inside of this folder.
However, it seems like nextcloud still have some issues when running it. What am I missing?

Error	PHP	chmod(): Operation not permitted at /var/www/html/lib/private/Log/File.php#86
Warning	no app in context	Invalid cliBasedCronUser data provided to provideInitialState by settings
Error	PHP	Trying to access array offset on value of type bool at /var/www/html/apps/settings/lib/Settings/Admin/Server.php#76


Which docker image are you using? AIO, LinuxServer, Nextcloud, something else?

Could you confirm those with ls -la or similar. Did you map them as docker volumes?

Try searching these errors against the forum and wider internet. Should turn up a bunch of info that could answer the issue for you. Tried searching part of this and found: cliBasedCronUser & Server.php error - #3 by werto165

Yea it seems like a common issue. I have been searching for few days, but unfortunately I can’t find an answer that I understand what to do. I’m using nextcloud’s docker image directly, and I did map my nextcloud/html folder to the docker.
Here is an image from portainer, where I setup my nextcloud as a stack:

Here is the ls -la result

To be more specific on what I don’t understand, here are two solutions might related to my problem:

usually you use ‘sudo -u www-data’ to run as user www-data (uid:33) and just sudo to run as root (uid:0)
Nextcloud Upgrade to 24.0.7 breaking tables - #4 by Vincent_Stans

sudo chown -R http:http /usr/share/webapps/nextcloud/config
sudo chmod 750 /usr/share/webapps/nextcloud/config
Chmod(): Operation not permitted at /usr/share/webapps/nextcloud/lib/private/Log/File.php#84 - #11 by mGurusamy

Both of them has some sort of hint saying I need to set the ownership correctly; however, the ownership of both of my problematic files are already set to 777. I even set the check_data_directory_permissions to false in config.php. My understanding is that anyone should be able to access it, but why can’t nextcloud?

Seeing another error now that might related to this:

The error will come out whenever I try to scroll through photos

Ok, so I gave up putting the data in my ntfs external drive, now the error is gone.
Originally I have everything on my external drive, including the html folder from nextcloud, and mariadb’s data folder with its backup folder. Now I only have mariadb’s back up folder in my external drive, and everything else in the ext4 main drive.
I guess Nextcloud is not very friendly with mounting things on ntfs drive. If I want to fix this issue in the future, I would probably research more on how they deal with ntfs drive in windows.
Leaving this thread for future users. GL

Are you sure you properly configured the ntfs drive on your server using ntfs-3g and fstab?

That filesystem is not natively supported in Linux, so definitely better to avoid if possible.

What would be the proper configuration nextcloud expect for mariadb? I mean I thought all read write permission (777) would take care of everything.
For experiment purpose, I moved mariadb to ntfs, and the error “could not create new folder” appears again, which could make sense if I had the wrong permission in fstab.

This is my current line in fstab that mount the ntfs drive:

UUID=irrelevant  /media/blk1t   ntfs  uid=1000,gid=1000,auto,nofail,rw    0           0

I see in this post that I suppose to add something like this

UUID="1476238C76236DA4" /mnt/2TB ntfs defaults,uid=33,guid=33,dmask=007,fmask=007

Not very familiar with fstab, so I have to figure out how to make both of my smb share and nextcloud happy at the same time…

Ownership should be www-data:www-data

I stopped using ntfs almost ten years ago, so I have little memory of how it works. It was one of the first things I stopped using when selfhosting. The problem in this case is simply misconfiguration.

If fstab is looking good, then confirm ownership matches www-data with a tool like chown.

You will not need smb if you’ve properly mounted the disk. Mounting disks is at the filesystem level as opposed to Nextcloud.

ok, so after using the command to change the ownership of the database folder (both db and db_backup), I don’t see the error anymore.
I think I misunderstood “ownership”. I thought if nextcloud can access it nextcloud will be happy, but in fact www-data has to “own” the folder to make nextcloud happy…
now I just need to figure out how to make my fstab file so that I can smb share my drive and change that folder’s permission at the same time…

You can use ntfs-3g to mount the ntfs disk in fstab. See NTFS-3G - ArchWiki

The fstab disk will be locally mounted via fstab with proper permissions. No smb steps needed.

I installed nextcloud docker to ext4 only, and here was the permission I got when everything was working fine (no permission error):

Then I cleared nextcloud to do a re-installation. I installed the db folder into my ntfs HDD, which is mounted using the ntfs3 driver (allowing me to store the permissions), I have this:
where html is also owned by www-data:www-data (same as what you see in the first figure).

I did get some errors when testing right after installation, but after rebooting m pi, I have not seen any error for two days. I think we are good now! Thanks