Skip to content

Instantly share code, notes, and snippets.

@jadwigo
Last active October 1, 2023 17:07
Show Gist options
  • Save jadwigo/6353a0d497b1f0b96dbcb93d510beeac to your computer and use it in GitHub Desktop.
Save jadwigo/6353a0d497b1f0b96dbcb93d510beeac to your computer and use it in GitHub Desktop.
Composer memory problems on digital ocean

If composer runs out of memory on digitalocean or another RAM limited cloud VM You need to create a swap drive

Create and activate the swapdrive as superuser And get back to the normal shell

sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=8192
sudo chmod 600 /var/swap.1
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1

After finishing up the swapdrive can be removed

sudo /sbin/swapoff /var/swap.1
sudo rm /var/swap.1

or from a root shell

/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=8192
chmod 600 /var/swap.1
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1
/sbin/swapoff /var/swap.1
rm /var/swap.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment