關(guān)于在linux 下 composer 安裝,更新插件出現(xiàn)內(nèi)存異常,交換錯(cuò)誤

The following exception is caused by a lack of memory and not having swap

Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-for details

http://www.linuxidc.com/Linux/2010-09/28915.htm ubuntu增加交換空間的步驟

提供了創(chuàng)建交換空間的方法

proc_open(): fork failed errors#

If composer shows proc_open() fork failed on some commands:

PHP Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar

This could be happening because the VPS runs out of memory and has no Swap space enabled.

free-mtotal used free shared buffers cachedMem:2048357169000237-/+ buffers/cache:1191928Swap:000

To enable the swap you can use for example:

/bin/ddif=/dev/zero of=/var/swap.1 bs=1M count=1024/sbin/mkswap/var/swap.1/sbin/swapon/var/swap.1

下面是整個(gè)過程

root@tyr:/var/www/html/laravel#./composer.phar global require "laravel/installer=~1.1"Changedcurrentdirectory to /root/.composer

PHP Fatal error:? Call to undefined method Fxp\Composer\AssetPlugin\Package\Version\VersionParser::parseLinks() in /root/.composer/vendor/fxp/composer-asset-plugin/Repository/VcsPackageFilter.php on line 272Fatal error: Call to undefined method Fxp\Composer\AssetPlugin\Package\Version\VersionParser::parseLinks() in /root/.composer/vendor/fxp/composer-asset-plugin/Repository/VcsPackageFilter.php on line 272root@tyr:/var/www/html/laravel#composer require "fxp/composer-asset-plugin:~1.0"./composer.json has been created

Loading composer repositories with package information

Updating dependencies (includingrequire-dev)- Installing fxp/composer-asset-plugin (v1.0.3)

Downloading: 100%The followingexceptionis 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 detailsPHP Fatal error:? Uncaughtexception'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:974Stack trace:#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///usr/loc...', 974, Array)#1 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(974): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)#2 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(784): Symfony\Component\Console\Application->getSttyColumns()#3 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(745): Symfony\Component\Console\Application->getTerminalDimensions()#4 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(675): Symfony\Component\Console\Application->getTerminalWidth()#5 phar:///usr/local/bin/com in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php on line 974Fatal error: Uncaughtexception'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:974Stack trace:#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///usr/loc...', 974, Array)#1 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(974): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)#2 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(784): Symfony\Component\Console\Application->getSttyColumns()#3 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(745): Symfony\Component\Console\Application->getTerminalDimensions()#4 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(675): Symfony\Component\Console\Application->getTerminalWidth()#5 phar:///usr/local/bin/com in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php on line 974root@tyr:/var/www/html/laravel#free -mtotal? ? ? used? ? ? free? ? shared? ? buffers? ? cached

Mem:? ? ? ? ? 488? ? ? ? 414? ? ? ? 74? ? ? ? 24? ? ? ? ? 1? ? ? ? 71-/+ buffers/cache:? ? ? ? 340? ? ? ? 147Swap:? ? ? ? ? ? 0? ? ? ? ? 0? ? ? ? ? 0root@tyr:/var/www/html/laravel#/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=10241024+0records in1024+0records out1073741824 bytes (1.1 GB) copied, 25.3413 s, 42.4 MB/s

root@tyr:/var/www/html/laravel#/sbin/mkswap /var/swap.1Setting up swapspace version 1, size = 1048572KiB

no label, UUID=60a9b908-925a-4161-8fca-7ae2d5a76154

root@tyr:/var/www/html/laravel#/sbin/swapon /var/swap.1root@tyr:/var/www/html/laravel#free -mtotal? ? ? used? ? ? free? ? shared? ? buffers? ? cached

Mem:? ? ? ? ? 488? ? ? ? 474? ? ? ? 13? ? ? ? 24? ? ? ? ? 2? ? ? ? 127-/+ buffers/cache:? ? ? ? 344? ? ? ? 143Swap:? ? ? ? 1023? ? ? ? ? 0? ? ? 1023root@tyr:/var/www/html/laravel#composer require "fxp/composer-asset-plugin:~1.0"./composer.json has been updated

Loading composer repositories with package information

Updating dependencies (includingrequire-dev)- Installing fxp/composer-asset-plugin (v1.0.3)

Loading from cache

Writing lockfileGenerating autoload files

root@tyr:/var/www/html/laravel#

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容