Magento – How to mount var session/cache to tmpfs

cachemagento-1.9

Could someone tell me how to mount my var session/cache folders to tmpfs? Also what would have to be done to unmount them if it does not work correctly? Could you please include the commands that are needed to stop/restart the needed service?

I know there are a lot of tutorials online to do this, however I am not sure if they apply to my system and each one I come across is a little different.

I am running:

  • CentOs 6 – 64Bit (v6.6)
  • Apache (2.4)
  • Percona (MySQL) (v5.6)
  • PHP 5.5.25 (via PHP-FPM)
  • Magento 1.9.0.1

Best Answer

vi /etc/fstab

tmpfs /path/to/var/cache tmpfs rw,uid=503,gid=503,size=2048M,nr_inodes=10k,mode=0755    0       0

mount /path/to/var/cache

Repeat above steps for var/session. Set size and nr_inodes as needed. Set uid and gid to user/group IDs of owner/group for these directories.

You can remove the tmpfs settings and re-create the directories if you need to undo it.