AWS EC2 Micro instance ErrorException: proc_open(): fork failed – Cannot allocate memory in phar的解決方法

AWS EC2 Micro instance ErrorException: proc_open(): fork failed – Cannot allocate memory in phar的解決方法

今天在AWS EC2 micro上面執行composer update的時候跳出了下面的錯誤訊息

PHP Fatal error:  Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///usr/local/bin/composer/vendor/symfony/console/S
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///usr/loc...', 990, Array)
#1 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(990): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
#2 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(832): Symfony\Component\Console\Application->getSttyColumns()
#3 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(797): Symfony\Component\Console\Application->getTerminalDimensions()
#4 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(731): 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 990

Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///usr/local/bin/composer/vendor/symfony/console/Symfon
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///usr/loc...', 990, Array)
#1 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(990): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
#2 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Conso
#3 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Conso
#4 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Conso
#5 phar:///usr/local/bin/com in phar:///usr/local/bin/composer/vendor/symfony/co

google了一下,很多人都說AWS EC2 micro instance遇到這個問題是無解必須把等級往上升一等才能解決,我不信邪,一樣在micro的機器上面做以下的修改

vi /etc/php.ini
把原本的 memory_limit=128M 改成 memory_limit=256M

然後重新啟動apache,再執行一次composer update就可以正常了,到目前為止composer都運作的很順利沒有遇到任何的問題

Post Tags :

阿維

阿維雜記本的偷懶維護者