💡 What to do if your RAM is full?
Via Bitnami Terminal
If your RAM is constantly maxed out, you don't necessarily need to pay for a bigger server. Try these two "free" fixes first:
Clear the OPCache: Sometimes the server holds onto old data. Run:
sudo /opt/bitnami/ctlscript.sh restart php-fpm
Add a "Swap" File: This is a trick where you tell the server to use a tiny bit of your Hard Drive space as "emergency RAM." It’s a bit slower, but it prevents the "unable to write" or "update failed" crashes.
Setting up a Swap File is a lifesaver for AWS Lightsail instances. Since your server likely has 512MB or 1GB of RAM, this 1GB Swap file acts like "emergency backup memory" on your hard drive. It keeps your site from crashing during heavy tasks like theme updates.
Run these commands one by one in your Lightsail terminal:
1. Create the Swap File
This creates a 1GB file on your hard drive.
sudo fallocate -l 1G /swapfile
(If you get an error saying "fallocate failed," use this instead: sudo dd if=/dev/zero of=/swapfile bs=1M count=1024)
2. Secure the File
For security, we make sure only the "root" system can read this file.
sudo chmod 600 /swapfile
3. Format & Activate
Now, tell the system that this file is meant to be used as RAM.
sudo mkswap /swapfilesudo swapon /swapfile
4. Make it Permanent
By default, the swap file disappears when you reboot. This command ensures it stays active forever.
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
How to verify it's working:
Run your favorite command from earlier:
free -h
You should now see 1.0G (or close to it) listed under the Swap row!
One Final Touch: "Swappiness"
To make the server use the swap file efficiently (only when it really needs to), run this:
sudo sysctl vm.swappiness=10echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
A value of 10 tells the server: "Use the real RAM as much as possible, and only use the Swap file as a last resort."