It seems that with PHP-cli midcom does not crash and this is apache related problem. But with test script above I get some errors to error log.
(midgard-core-gda:23025): GLib-WARNING : /build/buildd/glib2.0-2.16.6/glib/gmessages.c:387: could not find handler with id `10' for domain "midgard-core"
That same error occurs also with MidCOM 3 before zend heap error.