I found that many of my files and directories had incorrect permissions, so I executed the linux shell commands below to set all files to 644 and all directories to 755. I made a full backup before doing this since I couldn't find any documentation regarding any directories or files requiring different permissions. My moodle installation seems to work fine after this but proceed at your own risk
I executed these in my moodle root directory and they changed all files and directories recursively.
To find all non-644 files and change them to 644:
find -type f ! -perm 0644 -exec chmod 644 {} \;
To find all non-755 directories and change them to 755:
find -type d ! -perm 0755 -exec chmod 755 {} \;
I have no idea if this will solve the original problem but at least it's a quick and easy way to reset permissions.