Hello Guest    ログイン
top > Linux > eAccelerator for WordPress を使う
top > WordPress > eAccelerator for WordPress を使う

eAccelerator for WordPress を使う

カテゴリー: Linux, WordPress| 公開: 2008/9/24 | 更新: 2008/12/13 | コメント(0)

eAccelerator for WordPress はWordPressがHTMLを生成する際のPHPの変数をeAcceleratorにキャッシュさせようというもの。詳しい説明は http://wordpress.rauru-block.org/index.php/1582 を参照。XCache用APC用もある。

eAcceleratorのビルド

eAcceleratorのeaccelerator_getなどの変数キャッシュの関数を使えるようにしなければならない。前回のconfigureオプションでは有効になっていないので、もう一度ビルドする。

configureオプションで--with-eaccelerator-shared-memoryが必要。

$ tar jxvf eaccelerator-0.9.5.3.tar.bz2
$ cd eaccelerator-0.9.5.3/
$ phpize
$ ./configure --enable-eaccelerator --with-eaccelerator-shared-memory
$ make
$ sudo make install

eAccelerator for WordPress のインストール

eAccelerator for WordPressをダウンロードして、展開する。展開してできたobject-cache.phpをwp-contentディレクトリ直下に置く。pluginsディレクトリではないので注意。

速度は変わっていないが、MySQLへのクエリ数は大幅に減った。もともとMySQLのキャッシュが効いていたのだと思う。

管理画面でプラグインを反映するようにする

eAccelerator for WordPressを使っていると、プラグインを追加しても、管理画面に反映されない。

wp-admin/includes/plugin.phpを修正して、プラグインの取得にキャッシュを使わないようにする。

$ diff -u wp-admin/includes/plugin.php.orig wp-admin/includes/plugin.php
--- wp-admin/includes/plugin.php.orig   2008-09-09 21:16:00.000000000 +0900
+++ wp-admin/includes/plugin.php        2008-09-24 22:04:32.000000000 +0900
@@ -33,7 +33,7 @@

 function get_plugins($plugin_folder = '') {

-       if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins') )
+//     if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins') )
                $cache_plugins = array();

        if ( isset($cache_plugins[ $plugin_folder ]) )

[12/13 追記]
WordPressをアップグレードする度にplugin.phpを変更しなければならないので、object-cache.phpを修正して対応することにした。

$ diff -uw object-cache.php.orig object-cache.php
--- object-cache.php.orig       2007-10-28 06:56:08.000000000 +0900
+++ object-cache.php    2008-12-13 23:33:36.000000000 +0900
@@ -47,6 +47,9 @@

 function wp_cache_get($id, $flag = '')
 {
+       if ($id == 'plugins')
+               return false;
+
        global $wp_object_cache;

        return $wp_object_cache->get($id, $flag);

トラックバックURL

コメント送信

メールアドレスが公開されたり他で使用されたりすることはありません。