admin-ajax 500
臨下班,小客戶期望我的 Widgets 能夠修改一些內容。
點完 Save 按鈕,都準備關機了,卻看到菊花轉呀轉,始終始終保存不上。
得,扔個修改后的 index.html 上去,回家再說吧。
審查元素 Console 報了這個:
[Error] Failed to load resource: the server responded with a status of 500 (Internal Server Error) (admin-ajax.php, line 0)
先用了重啟大法、停插件大法,都無效之后。
開始搜 admin-ajax 500 ,結果吐出來一堆垃圾文章。
菲彩国际
甚至傻乎乎的照做,重裝了 php5-curl 還是解決不了問題。
沉住氣,查了一下 error.log (出問題果然還是要先查日志)
[Sun Sep 06 20:51:42.828453 2015] [:error] [pid 2987] [client 211.151.229.101:58371] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4915229 bytes) in /cuikai/www/html/wp-includes/wp-db.php on line 1173, referer: http://cnzhongka.com/wp-admin/widgets.php
再去查 wp-db.php on line 1173
得到一個線索,wp升級的時候會產生很多雜七雜八的玩意,導致后臺各種慢。
順藤摸瓜找到一篇 7 年前的文章,是通過直接刪數據庫冗余的臨時解決方案。
略過不表。
說一下怎么治根。
第一步:
打開 wp-includes/taxonomy.php file 跳轉到 4448 行
將
wp_schedule_single_event( ‘wp_batch_split_terms’, time() + MINUTE_IN_SECONDS );
修改為
wp_schedule_single_event( time() + MINUTE_IN_SECONDS, ‘wp_batch_split_terms’ );
以絕后患。
第二步:
創建一個 /wp-content/mu-plugins/fix.php 內容如下:
function clear_bad_cron_entries() {
// Fix incorrect cron entries for term splitting
$cron_array = _get_cron_array();
if ( isset( $cron_array['wp_batch_split_terms'] ) ) {
unset( $cron_array['wp_batch_split_terms'] );
_set_cron_array( $cron_array );
}
}
clear_bad_cron_entries();
菲彩国际在瀏覽器地址欄訪問一下該文件 cnzhongka.com/wp-content/mu-plugins/fix.php
ok 大功告成。
捎帶著,后臺各種操作也變快了,噗哈哈哈。