Maybe the issue is not the permission, but the ownership?
Does PHP run as the user of the vhost?
Could you please confirm if Ninja requires www-data ownership or permission of User, Group or Other type?
And what is the most restrictive permission allowed for Ninja to function and for its logs to be writable?
It only needs write access. But that depends on ownership and permission. For instance:
-If your PHP interpreter runs as user www-data, but you uploaded your files over FTP as user joe, then you’ll need to chmod to 0777 so that www-data can write joe‘s files/folders.
-If your PHP interpreter runs as user joe and you uploaded your files over FTP as user joe, then 0755 for folders and 644 for files will be fine.
If Ninja needs only write access at the User level, then as in the second case instead of 644 will 640 or 600 also work for the files?
I would keep 0644 so that it can be read by anyone.