How to configure MySQL/PHP to use less memory?-Collection of common programming errors
What you should do, is retain Linux, Mysql and PHP, but do away with Apache. Or at least, stop running PHP in-process with Apache.
The chances are you’re using the Apache prefork model with an in-process PHP module. This is very bad for memory efficiency on most workloads, because it keeps a heavy PHP process open even for HTTP connections which aren’t requesting any dynamic content just now.
What you want to do instead is use another web server (for example Nginx, but Apache would work too) and run PHP as a FastCGI daemon. This is easy to set up and googling for “PHP fastcgi” returns numerous examples.
You can then have a small, fixed number of “heavy” processes running PHP (No more than a couple per core, I reckon), but still have good capacity for running real applications, because “idle” HTTP connections, such as those serving keep-alives or waiting for requests don’t use up the “heavy” processes, only the lighter web server processes.
A web server which uses limited forking / few processes is probably better – such as Nginx, or Apache with a different thread model. This is incompatible with mod_php, which is why you need to run it as FastCGI instead.