From: https://unix.stackexchange.com/questions/294600/i-cant-enable-swap-space-on-centos-7
Follow these steps, it works on DigitalOcean's droplets. I tested. Change the amount 4096 according to your need
yum install nano -y
sudo dd if=/dev/zero of=/swapfile count=4096 bs=1MiB
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile