1.問(wèn)題
編譯運(yùn)行安裝php時(shí)姻政,突然報(bào)錯(cuò):
virtual memory exhausted: Cannot allocate memory
Makefile:931: recipe for target 'ext/fileinfo/libmagic/apprentice.lo' failed
make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1
很明顯內(nèi)存不足了···
free -h 看下
total used free shared buff/cache available
Mem: 983M 123M 762M 776K 97M 741M
Swap: 0B 0B 0B
2.解決
沒(méi)得辦法呀,買(mǎi)的機(jī)器就是1G內(nèi)存的岂嗓,只能用虛擬內(nèi)存解決了
//創(chuàng)建個(gè)存放緩存文件的文件夾
sudo mkdir vm
//創(chuàng)建一個(gè)2G的虛擬緩存區(qū)
sudo dd if=/dev/zero of=/opt/vm/swap bs=1024 count=2048000
//返回這個(gè)即創(chuàng)建成功
2048000+0 records in
2048000+0 records out
2097152000 bytes (2.1 GB, 2.0 GiB) copied, 14.7162 s, 143 MB/s
//轉(zhuǎn)換為SWAP分區(qū)
sudo mkswap /opt/vm/swap
//返回這即轉(zhuǎn)換成功
mkswap: /opt/vm/swap: insecure permissions 0644, 0600 suggested.
Setting up swapspace version 1, size = 2 GiB (2097147904 bytes)
no label, UUID=5f2dc3e3-7732-421c-95bd-9bb23c20bcab
//啟用這個(gè)緩存區(qū)
sudo swapon /opt/vm/swap
//返回這即成功啟用
swapon: /opt/vm/swap: insecure permissions 0644, 0600 suggested.
3.驗(yàn)證
free -h 看下汁展,添加上了應(yīng)該如下所示:
total used free shared buff/cache available
Mem: 983M 118M 63M 768K 801M 716M
Swap: 2.0G 0B 2.0G
4.繼續(xù)php的安裝
Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
clicommand.inc
invertedregexiterator.inc
directorygraphiterator.inc
directorytreeiterator.inc
pharcommand.inc
phar.inc
Build complete.
Don't forget to run 'make test'.
果然可以了,哈哈