You might also be interested in the admin docs 244 for running the OCC command - notably, it should be run as your web user (whatever user is running Apache/nginx).
As an example, here’s how I run OCC on my Ubuntu setup:
sudo -u www-data php /var/www/nextcloud/occ
I could leave out the ‘php’ part, but this way I don’t have to worry about setting execute permissions.