• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

composer install, mmap() failed: [12] Cannot allocate memory

php 搞代码 4年前 (2022-01-23) 59次浏览 已收录 0个评论
文章目录[隐藏]

阿里云centos7环境中, 内存1G, 当我执行composer require hwi/oauth-bundle时。 get一个错误,

<code>mmap() failed: [12] Cannot allocate memorySegmentation fault</code>

下面是我composer.json文件

<code class="json">{"name": "symfony/framework-standard-edition","license": "MIT","type": "project","description": "The \"Symfony Standard Edition\" distribution","autoload": {    "psr-4": { "": "src/" },    "classmap": [ "app/AppKernel.php", "app/AppCache.php" ]},"autoload-dev": {    "psr-4": { "Tests\\": "tests/" }},"require": {    "php": ">=5.5.9",    "symfony/symfony": "3.0.*",    "doctrine/orm": "^2.5",    "doctrine/doctrine-bundle": "^1.6",    "doctrine/doctrine-cache-bundle": "^1.2",    "symfony/swiftmailer-bundle": "^2.3",    "symfony/monolog-bundle": "^2.8",    "sensio/distribution-bundle": "^5.0",    "sensio/framework-extra-bundle": "^3.0.2",    "incenteev/composer-parameter-handler": "^2.0",    "knplabs/knp-paginator-bundle": "^2.5",    "vich/uploader-bundle": "^1.0",    "gregwar/captcha-bundle": "^2.0"},"require-dev": {    "sensio/generator-bundle": "^3.0",    "symfony/phpunit-bridge": "^3.0"},"scripts": {    "post-install-cmd": [        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"    ],    "post-update-cmd": [        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"    ]},"config": {    "platform": {        "php": "5.5.9"    }},"extra": {    "symfony-app-dir": "app",    "symfony-bin-dir": "bin",    "symfony-var-dir": "var",    "symfony-web-dir": "web",    "symfony-tests-dir": "tests",    "symfony-assets-install": "relative",    "incenteev-paramet<div>本文来*源gaodai^.ma#com搞#代!码网</div><pre>搞gaodaima代码

ers”: { “file”: “app/config/parameters.yml” }, “branch-alias”: { “dev-master”: “3.0-dev” }}

是由于内存不足导致的吗, 可有时候用conposer install能安装成功, 有时候就报这个错了, why

回复内容:

阿里云centos7环境中, 内存1G, 当我执行composer require hwi/oauth-bundle时。 get一个错误,

<code>mmap() failed: [12] Cannot allocate memorySegmentation fault</code>

下面是我composer.json文件

<code class="json">{"name": "symfony/framework-standard-edition","license": "MIT","type": "project","description": "The \"Symfony Standard Edition\" distribution","autoload": {    "psr-4": { "": "src/" },    "classmap": [ "app/AppKernel.php", "app/AppCache.php" ]},"autoload-dev": {    "psr-4": { "Tests\\": "tests/" }},"require": {    "php": ">=5.5.9",    "symfony/symfony": "3.0.*",    "doctrine/orm": "^2.5",    "doctrine/doctrine-bundle": "^1.6",    "doctrine/doctrine-cache-bundle": "^1.2",    "symfony/swiftmailer-bundle": "^2.3",    "symfony/monolog-bundle": "^2.8",    "sensio/distribution-bundle": "^5.0",    "sensio/framework-extra-bundle": "^3.0.2",    "incenteev/composer-parameter-handler": "^2.0",    "knplabs/knp-paginator-bundle": "^2.5",    "vich/uploader-bundle": "^1.0",    "gregwar/captcha-bundle": "^2.0"},"require-dev": {    "sensio/generator-bundle": "^3.0",    "symfony/phpunit-bridge": "^3.0"},"scripts": {    "post-install-cmd": [        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"    ],    "post-update-cmd": [        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"    ]},"config": {    "platform": {        "php": "5.5.9"    }},"extra": {    "symfony-app-dir": "app",    "symfony-bin-dir": "bin",    "symfony-var-dir": "var",    "symfony-web-dir": "web",    "symfony-tests-dir": "tests",    "symfony-assets-install": "relative",    "incenteev-parameters": {        "file": "app/config/parameters.yml"    },    "branch-alias": {        "dev-master": "3.0-dev"    }}</code>

是由于内存不足导致的吗, 可有时候用conposer install能安装成功, 有时候就报这个错了, why

可以尝试以下:

  1. 查看服务器中是否提交了composer.lock文件,若没有,提交composer.lock文件后执行composer install(假设题主使用了版本控制,本地开发,服务器同步)

  2. 查看当前PHP版本,如果不是最新版(PHP7),则升级至最新版

  3. 如果以上解决不了,则考虑是否Linux系统安装时没有创建Swapfile,尝试创建后重试

  4. 另外,可以考虑增加php.ini配置文件中对内存大小的限制memory_limit

可以尝试增加 swap 空间大小解决该问题

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

上述增加 1G 的 swap 空间,可以试试哦


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:composer install, mmap() failed: [12] Cannot allocate memory

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址