Apache serve file from RAM Apache serve file from RAM apache apache

Apache serve file from RAM


I'm no expert on this topic, but here's what I would try as a basic approach:

I'd keep my application code (including resources like CSS, JS, etc. - to keep it simple) in a location on the HDD. I'd have a RAM mount like:

vi /etc/fstabtmpfs       /mnt/ramdisk tmpfs   nodev,nosuid,noexec,nodiratime,size=1024M   0 0

and on system startup I'd copy from the HDD over to the RAM mount. Then I'd have the HTTP server (apache) point to the RAM mount, also everything inside of PHP will load code from the RAM mount, not the original location (for the purpose of rutime, the HDD source location does not exist).

For actual content I'd use an in-memory DB. If the content is media-rich some RAM cache like varnish can be used for that part.

There are of course variation to this strategy, or maybe even better solutions, but this also depends on your particular conditions, and you haven't said too much about those.