by Peter Bowen.
I find I have to put the following permissions in
sudochown -R root:apache /data/moodledata/{cache,filedir,lang,temp}
sudochmod -R g+rw,o-rwx /data/moodledata/{cache,filedir,lang,temp}