配置swap

今天更新的时候,到composer出错了.显示内存耗尽.

- Installing league/plates (3.3.0): Loading from cache
The following exception is caused by a lack of memory or swap, or not having swap configured
Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details

PHP Warning: proc_open(): fork failed - Cannot allocate memory in phar:///var/www/www.dehua.de/20180202-1605/dehua_web/source/composer.phar/vendor/symfony/console/Application.php on line 973

Warning: proc_open(): fork failed - Cannot allocate memory in phar:///var/www/www.dehua.de/20180202-1605/dehua_web/source/composer.phar/vendor/symfony/console/Application.php on line 973

[ErrorException]
proc_open(): fork failed - Cannot allocate memory

还好有帮助链接,连忙设置了swap


xxx:/var/www/www.dehua.de$ free -m
total used free shared buffers cached
Mem: 992 639 352 53 11 282
-/+ buffers/cache: 345 646
Swap: 0 0 0


xxx:/var/www/www.dehua.de$ sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024

1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 14.2447 s, 75.4 MB/s


xxx:/var/www/www.dehua.de$ sudo /sbin/mkswap /var/swap.1
Setting up swapspace version 1, size = 1048572 KiB
no label, UUID=31be5492-a29f-4647-9c74-0eb5407c3523


xxx/var/www/www.dehua.de$ sudo /sbin/swapon /var/swap.1
xxx/var/www/www.dehua.de$ free -m
total used free shared buffers cached
Mem: 992 920 71 53 12 565
-/+ buffers/cache: 342 649
Swap: 1023 0 1023

再次运行composer,故障排除.