The error is exactly as the message says, PHP is running out of it's allocated memory.
I can't see anything in the snippet you've given that look particularly memory hungry, but something is using enough.
If it was working on a different server (windows or otherwise), I would guess the php configuration is different. The relevant php.ini is "memory_limit" which defaults to 128M (
PHP: Description of core php.ini directives - Manual), but your debian config changes that to 64M (apparently, I thought their default was less than that, but that's what your error message says). So you might want to look at setting that up to the same as the windows config.