This creates a 2 GB Swap file. You can change this in the first line and write 4G instead of 2G for a 4 GB Swap for example.
sudo fallocate -l 2G /swapfile
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo nano /etc/fstab -> add at bottom: /swapfile none swap sw 0 0