There is a special directory /tmp - thats writeable by anyone. When apache itself need to create some files it uses /tmp, because its running as user nobody and can't write neither in root directories nor any home dir.
And your scripts should act that way.