无法在MacOS Local中安装/更新插件Wordpress

时间:2018-08-14 02:26:09

标签: php wordpress

我正在使用macOS的默认Apache。我的wp网站无法安装新插件或更新插件。 但这在实时站点中正常运行。这些是我尝试安装新插件时看到的列表错误:

  

错误通知:安装失败:内部服务器错误

     

立即安装按钮状态:更新失败!

     

在控制台调试中,我看到: ... / wp-admin / admin-ajax.php 500(内部服务器   错误)

我试图以某种方式进行搜索和操作,例如:更改chown,对777的权限,添加define('FS_METHOD','direct'),更改memory_limit ... 但仍然不起作用。

因此我经历了整个过程,当我在文件@set_time_limit( 300 );的第450行的.../wp-admin/includes/class-wp-upgrader.php行中注释时,我看到它正在工作。但是我不明白为什么会这样?

public function install_package( $args = array() ) {
    global $wp_filesystem, $wp_theme_directories;

    $defaults = array(
        'source' => '', // Please always pass this
        'destination' => '', // and this
        'clear_destination' => false,
        'clear_working' => false,
        'abort_if_destination_exists' => true,
        'hook_extra' => array()
    );

    $args = wp_parse_args($args, $defaults);

    // These were previously extract()'d.
    $source = $args['source'];
    $destination = $args['destination'];
    $clear_destination = $args['clear_destination'];

    //@set_time_limit( 300 ); **If I comment at here it's working**

    if ( empty( $source ) || empty( $destination ) ) {
        return new WP_Error( 'bad_request', $this->strings['bad_request'] );
    }
    $this->skin->feedback( 'installing_package' );
....
}

有人可以建议我如何解决此问题吗?

谢谢

1 个答案:

答案 0 :(得分:0)

为保护Web服务器免受滥用,对PHP脚本的运行时间设置了时间限制。例如,如果您的服务器收到100个没有时间限制的请求,则它们可能永远运行并占用整个RAM。

本地计算机的问题是插件安装的执行时间大于300秒(5分钟)。这可能是由Internet速度或Apache引起的。

有3种解决方案:

选项1:

与您一样注释@set_time_limit( 300 );,但不要在生产中更新文件。

选项2:

将此行添加到wp-config.php

ini_set('max_execution_time', 0);

与选项1相同,因此请勿在生产中更新文件。

选项3:

使用更好的本地开发环境(推荐),例如VCCW