我在 digital ocean 中有一朵云,那里有1 GB的内存。
我需要安装docker,laravel,mysql,nginx环境,我找到了laradock并正常安装了它,但是在容器中运行composer时,我返回了内存限制错误。
运行错误:composer安装
root@b9864446a1e1:/var/www/site# composer install
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 677388288) (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52
Fatal error: Out of memory (allocated 677388288) (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52
尝试更改内存时出错。
WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
最佳答案
发生这种情况是因为VPS内存不足,并且没有启用交换空间。
free -m
total used free shared buffers cached
Mem: xxxx xxx xxxx x x xxx
-/+ buffers/cache: xxx xxxx
Swap: 0 0 0
要启用交换,您可以使用例如:
/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1
您可以在this tutorial from DigitalOcean之后创建一个永久交换文件。
关于mysql - Composer 安装的内存限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60263830/