
Please apply this on your own risk.
Long version: https://www.digitalocean.com/community/tutorials/how-to-configure-virtual-memory-swap-file-on-a-vps
Create a swap disk:
cd /var
touch swap.img
chmod 600 swap.img
Resize the file:
Change the size according to your needs 1024 = 1 GB
dd if=/dev/zero of=/var/swap.img bs=1024k count=1024
Convert file to swap area:
mkswap /var/swap.img
Enable the swap area:
swapon /var/swap.img
To auto enable swap after reboot:
echo “/var/swap.img none swap sw 0 0” >> /etc/fstab