Chmod(): Operation not permitted at /usr/share/webapps/nextcloud/lib/private/Log/File.php#84

I did have the above problem. I just fixed it and hope this helps you as well
Fixes:
There is a directory called config with in /usr/share/webapps/nextcloud directory. Interestingly all the files/folders with in this config folder owned by nextcloud. I have no idea how does nextcloud user profile come into my system. So I make sure that my php-fpm service is using correct user and group details as like my nginx web server(php-fpm service user/group details can be verified at /etc/php/php-fpm.d/www.conf).
so I recursively change the ownership and mode of the config folder as like the parent folder(nextcloud) as below

sudo chown -R http:http /usr/share/webapps/nextcloud/config
sudo chmod 750 /usr/share/webapps/nextcloud/config

Restarted both php-fpm service and nginx and now If I browse my domain, I am been greeted by nextcloud welcome page admin account creation etc…