If you are running Elastic Compute Cloud (EC2) nano instance in Amazon Web Services (AWS), you will definitely need to configure swap memory for it. Nano instance only has 0.5G of memory which is not enough to run most applications. Laravel for one will not run with 0.5G of memory.
To check your current free memory, use this.
free -h
In my example, I will be creating a 1G swap file in Ubuntu 20.04.
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
Once completed, check your current free memory again. You should see that swap memory changed to 1G. This configuration is not permanent and will be lost once you reboot or shutdown the instance. To make it permanent, run the command below.
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0'|sudo tee -a /etc/fstab