Chmod und touch Probleme

Ich habe folgende meldungen in der Log (immer wieder)

chmod(): Operation not permitted at /var/www/nextcloud/lib/private/Log/File.php#119

touch(): Utime failed: Operation not permitted at /var/www/nextcloud/lib/private/Files/Storage/Local.php#196

nextcloud v11.0.1 (stable)
previewgenerator v1.0.1
php v7.0.15

Kann mir einer helfen?

Der Webserver braucht Schreibrechte.

Wie mache ich das richtig?

meine permissions.sh:
wwwpath = '/var/www/' ocpath = '/var/www/nextcloud' htuser = 'www-data' htgroup = 'www-data' rootuser = 'root'

printf "chmod Files and Directories\n"
find ${wwwpath}/ -type f -print0 | xargs -0 chmod 0640
find ${wwwpath}/ -type d -print0 | xargs -0 chmod 0750
find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640
find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750
     
printf "chown Directories\n"
chown -R ${rootuser}:${htgroup} ${wwwpath}/
chown -R ${rootuser}:${htgroup} ${ocpath}/
chown -R ${htuser}:${htgroup} ${ocpath}/apps/
chown -R ${htuser}:${htgroup} ${ocpath}/assets/
chown -R ${htuser}:${htgroup} ${ocpath}/config/
chown -R ${htuser}:${htgroup} ${ocpath}/data/
chown -R ${htuser}:${htgroup} ${ocpath}/themes/
chown -R ${htuser}:${htgroup} ${ocpath}/updater/
chown -R ${htuser}:${htgroup} /upload_tmp/
chown -R ${htuser}:${htgroup} /var/nc_data/
chown -R ${htuser}:${htgroup} /nextcloud-data/
     
chmod +x ${ocpath}/occ
     
printf "chmod/chown .htaccess\n"
if [ -f ${ocpath}/.htaccess ]
then
chmod 0644 ${ocpath}/.htaccess
chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
fi
if [ -f ${ocpath}/data/.htaccess ]
then
chmod 0644 ${ocpath}/data/.htaccess
chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess
fi 

chmod 0644 ${ocpath}/.user.ini
chmod 600 /etc/letsencrypt/live/nextcloud.bmk-media.de/fullchain.pem
chmod 600 /etc/letsencrypt/live/nextcloud.bmk-media.de/privkey.pem
chmod 600 /etc/letsencrypt/live/nextcloud.bmk-media.de/privatkey.pem
chmod 600 /etc/letsencrypt/live/nextcloud.bmk-media.de/chain.pem
chmod 600 /etc/letsencrypt/live/nextcloud.bmk-media.de/cert.pem
chmod 600 /etc/ssl/certs/dhparam.pem

Kann keiner helfen?

The solution is:

chown -R ${rootuser}:${htgroup} ${ocpath}/ to chown -R ${htuser}:${htgroup} ${ocpath}/ fixed the restore problem for me.