Ive been trying to be cheap with my DigitalOcean WordPress installation. I use a $5/month 1GB memory droplet which works pretty well. The problem is that if you run out of physical memory, then MySQL will crash and you get the dreaded, “No database connection message”.
Here is what I’m doing about it:I created a swapfile since I have 25GB, this will make it slower, but the crashes are less likely. with 1GB. of memory, the default is no swapfile for performance reasons and it’s not so great for the SSDs that are in the shared server. It’s not super complicated, you basically create file wit
sudo fallocate -l 1G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile # In my case, I had forgotten to update /etc/fstab echo '/swapfile swap swap defaults 0 0' > /etc/fstab shutdown now -r
With the free command, you can see how much memory is being used. In my very unused WordPress, it is 98MB free, so not very much and 262MB available if you kick out the caches.
But to get going right away, you need to restart apache2 and restart mysql with status checking and then a restart
# see what the status of the two services are
sudo service apache2 status
sudo service mysql status
# restart as usually mysql has crashed
sudo service apache2 restart
sudo service mysql restart
# If this doesn't work you can try a full shutdown
sudo shutdown -r now
But the right long term solution is to migrate to a JAMStack like Hugo and then get free hosting at Netlify. They make it easy to migrate and all the code is now checked into GitHub which is way better.