/var/www/nextcloud not accessible (Permission denied)

These folders are usually owned by the web server user, which is www-data. So you need to become root (sudo -i) to enter these folders.

Run the following command to see the ownership and file permissions:
ls -al /var/www