Turn from: http://www.cnblogs.com/chenpingzhao/p/4820814.html
Problem Description:
The Linux server was purchased with 512MB of memory.
When compiling PHP will prompt: Virtual memory Exhausted:cannot Allocate memory, compilation failed.
Workaround:
This problem occurs because the server does not have enough memory to cause the compilation to fail.
The purchase of Linux server, does not give you the allocation of virtual memory, so you can increase the virtual memory by the way to solve
1 2 3 4 5 |
[Root@iz25p0h5gthz ~]# free-m      &NB sp; total used free shared buffers Cached Mem : 994 707 287 0 11 -/+ Buffers/cache : 638 356 Swap: 0 0 0 |
Second Step
1 2 3 4 5 6 7 8 |
[Root@iz25p0h5gthz ~]# mkdir/usr/img/[Root@iz25p0h5gthz ~]# rm-rf/usr/img/swap [Root@iz25p0h5gthz ~]# dd if =/dev/zero of=/usr/img/swap bs=1024 count =2048000 2048000+0 Records in 2048000+0 Records out 209715 Bytes (2.1 GB) copied, 48.7514, 43.0 MB/s |
Third Step
1 2 3 4 5 6 7 8 9 10 11 |
[Root@iz25p0h5gthz ~]# 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 KiB no label, uuid=9982f566-9e44-4495-be0b-51d309873112 [Root@iz25p0h5gthz ~]# Swapon/usr/img/swap [Root@iz25p0h5gthz ~]# free-m & nbsp; total used free shared buffers Cached mem: 994 924 70 0 1 -/+ buffers/cache: 653 swap: 1999 0 1999 |
You can turn off swap when you've finished using