作曲家用完"unlimited memory"



>免责声明:我是壳牌菜鸟。

目标

安装 Drupal 地址模块。

尝试 1composer 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

尝试 2php -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

尝试 3php -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

笔记

  • 运行whm.mydomainname.com/cpsessSESSIONID/scripts2/doautofixer?autofix=safesshrestart后只能通过 SSH 访问命令行
  • 作曲家位于/opt/cpanel/composer/bin/composer意外安装的根目录中也有composer.phar
  • 所有命令都在我的Drupal安装public_html的根目录中运行

资源

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"
        }
    ]
}

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

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

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

相关内容

  • 没有找到相关文章

最新更新