【问题标题】:Cannot Increase WP Memory Limit无法增加 WP 内存限制
【发布时间】:2018-03-03 03:14:59
【问题描述】:

我想将memory_limit 增加到512M,但这对我不起作用。我正在使用 WampServer。这就是我所做的:

  • .htaccess 中,我在底部添加了php_value memory_limit 512M
  • 在位于D:\wamp\bin\php\php7.0.10php.ini 我有memory_limit = 512M
  • 在 wp-config.php 中,我在底部添加了define( 'WP_MEMORY_LIMIT', '512M' );

但是,一个插件仍然显示我有 40M,因为它建议我至少有 128MB。这就是我在defult-constants.php 中的内容

    if ( ! defined( 'WP_MEMORY_LIMIT' ) ) {
    if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
        define( 'WP_MEMORY_LIMIT', $current_limit );
    } elseif ( is_multisite() ) {
        define( 'WP_MEMORY_LIMIT', '64M' );
    } else {
        define( 'WP_MEMORY_LIMIT', '40M' );
    }
}

【问题讨论】:

  • 更改配置值后是否重启了 apache?
  • 哦等等; at the bottom,你的意思是之后 wp-settings.php 包括在内?在这种情况下; WP_MEMORY_LIMIT 已经设置(并且不能再次更改)。可能会触发错误,但默认情况下它是隐藏的
  • 重启apache?意思是重启服务器吧?
  • 是的,WAMP 代表; Windows-Apache-MySQL-PHP。这是完整的堆栈。重新启动整个服务器应该可以工作,但只有 apache 应该可以解决问题。仅当您更改 php.ini 值(或 httpd.conf 时)才需要。
  • 嘿,我已按照您的指示将其放在该行之上。我也上班!因为我删除了我在 defult-constants.php 中所做的检查。谢谢!!

标签: php wordpress .htaccess memory-limit


【解决方案1】:

我刚刚找到了答案。只需在defult-constants.php 中输入512M

    if ( ! defined( 'WP_MEMORY_LIMIT' ) ) {
    if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
        define( 'WP_MEMORY_LIMIT', $current_limit );
    } elseif ( is_multisite() ) {
        define( 'WP_MEMORY_LIMIT', '64M' );
    } else {
        define( 'WP_MEMORY_LIMIT', '40M' );
    }
}

所以现在我有

    if ( ! defined( 'WP_MEMORY_LIMIT' ) ) {
    if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
        define( 'WP_MEMORY_LIMIT', $current_limit );
    } elseif ( is_multisite() ) {
        define( 'WP_MEMORY_LIMIT', '512M' );
    } else {
        define( 'WP_MEMORY_LIMIT', '512M' );
    }
}

【讨论】:

  • 我建议不要这样做。这将被您的下一次 wordpress 升级覆盖...它应该在您的 wp-config.php 中。阅读我上面的评论,这可能是你的问题
  • 是的,先生。我已经删除了它:) 非常感谢。我是新手。
猜你喜欢
  • 2015-08-31
  • 2014-11-17
  • 1970-01-01
  • 2022-01-03
  • 2019-02-19
  • 2019-03-13
  • 2023-03-09
  • 2014-04-24
相关资源
最近更新 更多