我在Digital Ocean下的Ubuntu托管(我是在两周前创建的)中出现内存错误:
root@ubuntu-boxBooking-Dev:/var/www/html/box-booking# lsb_release -d; uname -r; uname -i
Description: Ubuntu 16.04.4 LTS
4.4.0-130-generic
x86_64
root@ubuntu-boxBooking-Dev:/var/www/html/box-booking# free -m
total used free shared buff/cache available
Mem: 992 325 562 35 104 518
Swap: 0 0 0
我安装了laravel 5.5应用程序。我从git提取更改,不得不安装干预/图像:
# composer require intervention/image
Using version ^2.4 for intervention/image
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
mmap() failed: [12] Cannot allocate memory
mmap() failed: [12] Cannot allocate memory
PHP Fatal error: Out of memory (allocated 586162176) (tried to allocate 20480 bytes) in /usr/share/php/Composer/DependencyResolver/Rule.php on line 66
Fatal error: Out of memory (allocated 586162176) (tried to allocate 20480 bytes) in /usr/share/php/Composer/DependencyResolver/Rule.php on line 66
root@ubuntu-boxBooking-Dev:/var/www/html/box-booking#
root@ubuntu-boxBooking-Dev:/var/www/html/box-booking# lsb_release -d; uname -r; uname -i
我也尝试过:
# composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Removing doctrine/dbal (v2.6.3)
The following exception is caused by a lack of memory and not having swap configured
Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details
我明白了 没有配置交换 上面的错误描述和上面的free命令中的0值。问题和如何解决?
还在Digital Ocean下安装Ubuntu托管我没有注意到任何交换选项...
Aslo可以重启系统解决问题吗? 通常,我会重启在root下运行的ubuntu(我在笔记本电脑上使用kubuntu 18):
reboot
在我的情况下还是在其他命令中必须运行?
谢谢!
答案 0 :(得分:0)
到目前为止,添加交换似乎是唯一的解决方法。参考:https://github.com/composer/composer/issues/1898
过程:
df -h
dd if=/dev/zero of=/swapfile bs=1M count=1024
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
mkswap /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo 'echo "/swapfile none swap defaults 0 0" >> /etc/fstab' | sudo sh
free -m