php - 无法在 macOS 本地安装/更新插件 wordpress
问题描述
我正在使用 macos 的默认 apache。我的 wp 网站无法安装新插件或更新插件。但这在现场工作正常。这些是我在尝试安装新插件时看到的列表错误:
错误通知:安装失败:内部服务器错误
现在按钮安装状态:更新失败!
在控制台调试中,我看到:.../wp-admin/admin-ajax.php 500(内部服务器错误)
我尝试搜索并以某些方式进行操作,例如:更改 chown,权限为 777,添加定义('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' );
....
}
谁能建议我如何解决这个问题?
谢谢
解决方案
为了保护 Web 服务器免受滥用,PHP 脚本可以运行多长时间设置了时间限制。例如,如果您的服务器收到 100 个没有时间限制的请求,它们可能会永远运行并占用整个 RAM。
您本地机器的问题是插件安装的执行时间大于 300 秒(5 分钟)。它可能是由互联网速度或 Apache 引起的。
有 3 个选项可以修复它:
选项1:
像你一样注释掉@set_time_limit( 300 );
,但不要在生产中更新文件。
选项 2:
将此行添加到wp-config.php
:
ini_set('max_execution_time', 0);
它与选项 1 相同,因此不要在生产时更新文件。
选项 3:
使用更好的本地开发环境(推荐),例如VCCW。
推荐阅读
- javascript - 如何让 HTML 按钮执行 Electron JS 功能
- javascript - 如何使用 testcafe 删除或替换 monaco 编辑器上的文本?
- python - Keras:改变训练模型的结构
- youtube - 列出频道订阅仅返回我的频道
- python - 从 Python 设置 NSSpeechSynthesizer 模式
- python - 在 Tkinter 中看不到图像?
- gnuplot - Gnuplot 以文本列为 X 轴绘制数据
- c# - 使用文件数组解析 FormData [] - 到控制器并保存到 PSQL
- javascript - Chrome 编译问题
- image - SwiftUI:将 SF 图标放入行高