How can I limit apache2's resources?

view story

http://stackoverflow.com – I have a very slow home server (raspberry pi) with 700 MHz CPU. When I develop some sites, it sometimes happens that I input a large (5 MB) .jpg file into an image resizer (imagecreatefromjpeg(), imagecreatetruecolor(), imagecopy()) which causes the server to hang. I'd say it's processing the file, but even when I wait for minutes, it never ends. The problem is that I cannot even access the shell to stop/restart apache2; the only solution is to power off the server completely. I was wondering whether there's any way to limit HW resources for apache2; for example if I could limit only 80% CP (HowTos)