Problem Description:
The Linux server has 512MB of memory for the Linux server purchased.
When compiling PHP, you will be prompted: virtual memory Exhausted:cannot Allocate memory, compile failed.
Workaround:
The problem occurs because the server does not have enough memory to cause compilation to fail.
Instead of allocating virtual memory to the Linux server you purchased, you can resolve it by adding virtual memory yourself.
[Email protected] ~]# free-m total used free shared buffers cachedmem: 994 707 287 0 57-/+ buffers/cache: 638 356 Swap: 0 0
Step Two
[Email protected] ~]# mkdir/usr/img/ [[email protected] ~]# rm-rf/usr/img/swap[[email protected] ~]# DD If=/dev/zero of=/usr/img/swap bs=1024 count=2048000 2048000+0 Records in2048000+0 records out2097152000 bytes ( 2.1 GB) copied, 48.7514 s, 43.0 MB/s
Step Three
[Email protected] ~]# mkswap/usr/img/swap mkswap:/usr/img/swap:warning:don ' t erase bootbits sectors on Whole disk. Use-f to force. Setting up Swapspace version 1, size = 2047996 kibno label, Uuid=9982f566-9e44-4495-be0b-51d309873112[[email protected] ~] # swapon/usr/img/swap [[email protected] ~]# free-m total used free shared buffers Cachedmem: 994 924 0 1 269-/+ buffers/cache: 653 340 Swap: 1999 0 1999
You can turn off swap when you are finished using
[[email protected] img]# Swapoff swap
Virtual Memory Exhausted:cannot Allocate memory