简体   繁体   English

使用 Capifony 部署 Symfony2 项目时出现 PHP 致命错误

[英]PHP Fatal error when deploying Symfony2 project using Capifony

When deploying my Symfony2 project to my server I occassionally get the following error:将我的 Symfony2 项目部署到我的服务器时,我偶尔会收到以下错误:

PHP Fatal error:  Uncaught exception 'ErrorException' with message 'proc_open(): 
fork failed - Cannot allocate memory' in 
in phar:///var/www/xyz.co.uk/releases/20130320161122/composer.phar/vendor/
symfony/console/Symfony/Component/Console/Application.php:982

Update更新

Full error message is below which occurs after --> Updating Composer dependencies :以下是在--> Updating Composer dependencies后发生的完整错误消息:

*** [err :: x.xx.xx.xxx] PHP Fatal error:  Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///var/www/xyz.co.uk/releases/20130320161815/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:982
*** [err :: x.xx.xx.xxx] Stack trace:
*** [err :: x.xx.xx.xxx] #0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///var/www...', 982, Array)
*** [err :: x.xx.xx.xxx] #1 phar:///var/www/xyz.co.uk/releases/20130320161815/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(982): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
*** [err :: x.xx.xx.xxx] #2 phar:///var/www/xyz.co.uk/releases/20130320161815/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(900): Symfony\Component\Console\Application->getSttyColumns()
*** [err :: x.xx.xx.xxx] #3 phar:///var/www/xyz.co.uk/releases/20130320161815/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(865): Symfony\Component\Console\ in phar:///var/www/xyz.co.uk/releases/20130320161815/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php on line 982
*** [deploy:update_code] rolling back
failed: "sh -c 'sh -c '\\''cd /var/www/xyz.co.uk/releases/20130320161815 && php composer.phar update --no-scripts --verbose --prefer-dist'\\'''" on x.xx.xx.xxx

This doesn't happen ALL the time but just sometimes.这不会一直发生,但有时会发生。 I've allocated 256M in my apache and cli php.ini file on the server but still sometimes receive the error.我已经在服务器上的 apache 和 cli php.ini 文件中分配了 256M,但有时仍会收到错误消息。

How much memory does Symfony require? Symfony 需要多少内存? Do I need to increase it further?我需要进一步增加吗? I thought this would be enough.我以为这就够了。

According to this post on GitHub: https://github.com/composer/composer/issues/945 It looks like you'll need at least 1GB of memory available to PHP.根据 GitHub 上的这篇文章: https : //github.com/composer/composer/issues/945看起来您至少需要 1GB 的内存可用于 PHP。

Symfony is quite the memory hog and while 1Gb may sound ridiculous, for the type of processing it's performing it's most definitely not out of the question. Symfony 是一个非常消耗内存的人,虽然 1Gb 可能听起来很荒谬,但对于它所执行的处理类型来说,它绝对不是不可能的。 If it's telling you you're out of memory, your only option is to add more memory.如果它告诉您内存不足,您唯一的选择就是添加更多内存。

You might also want to check back in a week or so and see if they haven't patched up some sort of memory leak as well.您可能还想在一周左右的时间回来检查一下,看看他们是否也没有修补某种内存泄漏。

Yes, Symfony was always heavier than most frameworks out there but this error is kinda ridiculous.是的, Symfony总是比那里的大多数框架更重,但是这个错误有点荒谬。 I'm saying this because my production machine has 512MB of RAM in total and 128M is allocated to PHP - and, still, application performs excellent.我这么说是因为我的生产机器总共有 512MB 的 RAM,128M 分配给 PHP - 而且,应用程序仍然表现出色。

Now, because complexity does play a major role here, where does you error occur ?现在,因为复杂性在这里起着重要作用,哪里发生错误 During the cache warm-up/clean?在缓存预热/清理期间? Are you trying to run some custom console command ?您是否正在尝试运行一些自定义控制台命令

Also, have you tried installing APC ?另外,您是否尝试过安装APC My application went blazing after doing that :)这样做后,我的应用程序变得异常火爆:)

Some symfony deployments needs a lot memory for update repositories.一些 symfony 部署需要大量内存来更新存储库。 Also if you use capifony you could get a lot memory errors.此外,如果您使用capifony,您可能会遇到很多内存错误。 The trick for deploy in small VPS or dedicated with less than 1-2 GB of RAM is create a SWAP where you will get store the memory need.在小型 VPS 或专用内存少于 1-2 GB 的情况下部署的技巧是创建一个 SWAP,您可以在其中存储所需的内存。 So for example you can try creating 1 GB of swap with this commands:例如,您可以尝试使用以下命令创建 1 GB 的交换空间:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM