Increase the available memory

Bitnami stacks for web applications install servers like Apache, MySQL, PostgreSQL and others. Some of these requires more than 1 GB of memory. If you have less than 1 GB of total memory, create a swap file to increase the available system memory.

Linux swap files allow a system to harness more memory than was originally physically available (RAM). Swap space is the area on the hard drive that holds memory pages that are inactive, freeing up physical memory for other uses.

It is recommended to have swap space in your system. Check your current swap space with the free command:

$ free -m
             total       used       free     shared    buffers     cached
Mem:           491        144        346          0          2         25
-/+ buffers/cache:        117        374
Swap:          975         81        894

From the output, the system has 419 MB of RAM and 975 MB of swap space.

It’s recommended that swap space should be equal to or bigger than the amount of physical memory (RAM). If you have less than 1 GB of RAM, create at least 1 GB of swap space. Follow these steps:

  • Identify a partition for the swap file and create it. If you have an ephemeral partition, that’s ideal:

    $ sudo dd if=/dev/zero of=/mnt/swap.0 bs=1024 count=1048576
    $ sudo mkswap /mnt/swap.0
  • Switch to using the root account and activate the swap area:

    $ sudo su
    $ echo "/mnt/swap.0 swap swap defaults 0 0" >> /etc/fstab
    $ swapon /mnt/swap.0
  • Check if the swap space was properly enabled with the free command or the command below:

    $ sudo swapon -s