作曲家耗尽“无限记忆”

时间:2018-03-14 22:24:18

标签: composer-php drupal-8 whm

免责声明:我是一个SHELL noob。

目标

安装Drupal Address module

试过

尝试1 composer require drupal/address

返回:

Using version ^1.3 for drupal/address
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

Fatal error: Out of memory (allocated 435945472) (tried to allocate 2254277 bytes) in phar:///opt/cpanel/composer/bin/composer/src/Composer/Json/JsonFile.php on line 270

(预计这会php -r "echo ini_get('memory_limit').PHP_EOL;"返回128M。)

尝试2 php -d memory_limit=-1 /opt/cpanel/composer/bin/composer require drupal/address

返回:

Using version ^1.3 for drupal/address
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

Fatal error: Out of memory (allocated 435683328) (tried to allocate 1069411 bytes) in phar:///opt/cpanel/composer/bin/composer/src/Composer/Util/RemoteFilesystem.php on line 419

尝试3 php -d memory_limit=-1 composer.phar require drupal/address

Using version ^1.3 for drupal/address
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

Fatal error: Out of memory (allocated 435945472) (tried to allocate 1069279 bytes) in phar:///home/venturec/public_html/composer.phar/src/Composer/Util/RemoteFilesystem.php on line 419

注释

资源的开发

composer diagnose

Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: *Blur*
Dev Public Key Fingerprint: *Blur*
OK
Checking composer version: OK
Composer version: 1.6.3
PHP version: 5.6.34
PHP binary path: /opt/cpanel/ea-php56/root/usr/bin/php

composer.json

{
    "name": "drupal/drupal",
    "description": "Drupal is an open source content management platform powering millions of websites and applications.",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "require": {
        "composer/installers": "^1.0.24",
        "wikimedia/composer-merge-plugin": "^1.4",
        "drupal/address": "^1.3"
    },
    "replace": {
        "drupal/core": "^8.4"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "config": {
        "preferred-install": "dist",
        "autoloader-suffix": "Drupal8"
    },
    "extra": {
        "_readme": [
            "By default Drupal loads the autoloader from ./vendor/autoload.php.",
            "To change the autoloader you can edit ./autoload.php.",
            "This file specifies the packages.drupal.org repository.",
            "You can read more about this composer repository at:",
            "https://www.drupal.org/node/2718229"
        ],
        "merge-plugin": {
            "include": [
                "core/composer.json"
            ],
            "recurse": false,
            "replace": false,
            "merge-extra": false
        },
        "installer-paths": {
            "core": ["type:drupal-core"],
            "modules/contrib/{$name}": ["type:drupal-module"],
            "profiles/contrib/{$name}": ["type:drupal-profile"],
            "themes/contrib/{$name}": ["type:drupal-theme"],
            "drush/contrib/{$name}": ["type:drupal-drush"],
            "modules/custom/{$name}": ["type:drupal-custom-module"],
            "themes/custom/{$name}": ["type:drupal-custom-theme"]
        }
    },
    "autoload": {
        "psr-4": {
            "Drupal\\Core\\Composer\\": "core/lib/Drupal/Core/Composer"
        }
    },
    "scripts": {
        "pre-autoload-dump": "Drupal\\Core\\Composer\\Composer::preAutoloadDump",
        "post-autoload-dump": [
          "Drupal\\Core\\Composer\\Composer::ensureHtaccess"
        ],
        "post-package-install": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",
        "post-package-update": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ]
}

1 个答案:

答案 0 :(得分:1)

您的Drupal在共享主机中运行,您的帐户下可分配的CPU /内存有限。将指令“ memory_limit ”设置为“ -1 ”并不意味着您可以在PHP脚本/命令中使用“无限”内存,这只意味着您可以使用你可以在该主机上分配的所有内存,只有435 + M(可能大约512M)。

如果你想留在那个共享主机上,那么你无能为力。 Drupal需要足够的内存来运行,并且在共享主机上优化Drupal的方法并不多。但是,您仍然可以尝试以下建议:

  1. 如果该主机上有PHP 7(您可以在cPanel中查看),请尝试在PHP 7下运行Drupal。这允许以更少的内存运行Drupal。
  2. 您可以手动下载模块,将其上传到主机,然后在Drupal管理面板中启用,而不是使用 Composer 维护Drupal。