我在 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
我懂了
没有配置交换
上面的错误描述和上面的免费命令中的 0 值。是问题吗?如何解决?
还在 Digital Ocean 下安装 Ubuntu 主机我没有注意到任何交换选项......
aslo 可以重启系统解决问题吗?
通常我会重新启动在 root 下运行的 ubuntu(我在笔记本电脑上使用 kubuntu 18):
reboot
这是我必须在我的情况下运行的还是其他更可取的命令?
谢谢!
最佳答案
添加交换似乎是目前唯一的解决方法。引用:https://github.com/composer/composer/issues/1898
过程:
df -h
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
sudo mkswap /swapfile
sudo chmod 600 /swapfile
sudo swapon /swapfile
echo 'echo "/swapfile none swap defaults 0 0" >> /etc/fstab' | sudo sh
free -m
关于ubuntu - ubuntu服务器上的Laravel内存不足错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51568160/