Drush耗尽了2097152字节的允许的内存大小

时间:2019-05-17 19:05:57

标签: drupal-8 drush

尝试在Ubuntu 18.04 Web服务器上运行Drush时,出现以下错误;

someMethod(event) {
    item.value = event;
    //Other stuff you were doing before
}

我已经检查了php.ini文件是否通过命令PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 12288 bytes) in /root/.composer/vendor/drush/drush/src/internal-forks/Config/Yaml/Parser.php on line 379 加载,这会给我输出;

php --ini

我已经编辑了Configuration File (php.ini) Path: /etc/php/7.2/cli Loaded Configuration File: /etc/php/7.2/cli/php.ini Scan for additional .ini files in: /etc/php/7.2/cli/conf.d Additional .ini files parsed: /etc/php/7.2/cli/conf.d/10-mysqlnd.ini, /etc/php/7.2/cli/conf.d/10-opcache.ini, /etc/php/7.2/cli/conf.d/10-pdo.ini, /etc/php/7.2/cli/conf.d/15-xml.ini, /etc/php/7.2/cli/conf.d/20-apcu.ini, /etc/php/7.2/cli/conf.d/20-apcu_bc.ini, /etc/php/7.2/cli/conf.d/20-calendar.ini, /etc/php/7.2/cli/conf.d/20-ctype.ini, /etc/php/7.2/cli/conf.d/20-curl.ini, /etc/php/7.2/cli/conf.d/20-dom.ini, /etc/php/7.2/cli/conf.d/20-exif.ini, /etc/php/7.2/cli/conf.d/20-fileinfo.ini, /etc/php/7.2/cli/conf.d/20-ftp.ini, /etc/php/7.2/cli/conf.d/20-gd.ini, /etc/php/7.2/cli/conf.d/20-gettext.ini, /etc/php/7.2/cli/conf.d/20-iconv.ini, /etc/php/7.2/cli/conf.d/20-intl.ini, /etc/php/7.2/cli/conf.d/20-json.ini, /etc/php/7.2/cli/conf.d/20-ldap.ini, /etc/php/7.2/cli/conf.d/20-mbstring.ini, /etc/php/7.2/cli/conf.d/20-mysqli.ini, /etc/php/7.2/cli/conf.d/20-pdo_mysql.ini, /etc/php/7.2/cli/conf.d/20-phar.ini, /etc/php/7.2/cli/conf.d/20-posix.ini, /etc/php/7.2/cli/conf.d/20-readline.ini, /etc/php/7.2/cli/conf.d/20-shmop.ini, /etc/php/7.2/cli/conf.d/20-simplexml.ini, /etc/php/7.2/cli/conf.d/20-sockets.ini, /etc/php/7.2/cli/conf.d/20-sysvmsg.ini, /etc/php/7.2/cli/conf.d/20-sysvsem.ini, /etc/php/7.2/cli/conf.d/20-sysvshm.ini, /etc/php/7.2/cli/conf.d/20-tokenizer.ini, /etc/php/7.2/cli/conf.d/20-wddx.ini, /etc/php/7.2/cli/conf.d/20-xmlreader.ini, /etc/php/7.2/cli/conf.d/20-xmlwriter.ini, /etc/php/7.2/cli/conf.d/20-xsl.ini, /etc/php/7.2/cli/conf.d/20-zip.ini 并设置了/etc/php/7.2/cli/php.ini,但问题仍然存在。

似乎在命令行上仍将内存限制设置为2MB。当我检查设置为输出memory_limit = 1024MB的网站时,可以看到phpinfo()等于1024MB。

请问有人可以解决我的问题吗?

1 个答案:

答案 0 :(得分:0)

您的计算机上可能运行着多个版本的PHP,请快速检查一下:which -a php

要查看drush php可执行文件和.ini文件的位置,请运行drush status。验证它首先依赖于正确的可执行文件(似乎它依赖于错误的PHP版本和/或配置,或者您编辑的.ini文件不是正确的)。

您有可能在$HOME/.drush//etc/drush中拖过特定的配置,请检查以下几行:

 PHP executable         :  /path/to/php
 PHP configuration      :  /path/to/php.ini

如果您需要更改PHP可执行文件路径,请使用DRUSH_PHP环境变量:

  

要使用特定版本的php运行Drush,而不是   您的shell定义的php,您可以将环境变量添加到   您的外壳程序配置文件名为.profile,.bash_profile,   .bash_aliases或位于您的主文件夹中的.bashrc:

export DRUSH_PHP='/path/to/php'

以下环境变量还可以控制Drush将使用的设置:

export PHP_INI='/path/to/php.ini'
export DRUSH_INI='/path/to/drush.ini'
export PHP_OPTIONS='-d memory_limit="2"' # you might have this overriding your base config !

请参阅Running a Specific php for Drush-这是drush 7.x文档,但与drush 8.x相同(尽管未在drush 9.x上进行过测试)。