1. 安装APC,下载APC源代码
phpize - 生成configure文件
./configure --with-php-config=/root/to/php/bin/php-config
make; make install
2. 编辑php.ini,例如
extension=apc.so
apc.enabled=1
apc.shm_size=128M
apc.ttl=7200
apc.user_ttl=7200
apc.enable_cli=1
这里需要注意一下,APC和ZO不能共存,需要把ZO注释掉
通过apc.php可以查看运行状态
3. 下载并安装drupal的APC模块
引用README中
APC normally has a limited memory allocation (32M) and should be used to cache the entries which are used most since it's the cache closest (and maybe fastest)
toPHP. When the memory allocated by APC is big enough to cache the entire drupal cache (to do so check the size of the cache_% tables in the database when the
cache is hot) you can use Step2b, if not use step 2a.
- Step 2a
Add the following code to your settings.php file:
/**
* Add APC Caching.
*/
$conf['cache_backends'] = array('sites/all/modules/apc/drupal_apc_cache.inc');
$conf['cache_class_cache'] = 'DrupalAPCCache';
$conf['cache_class_cache_bootstrap'] = 'DrupalAPCCache';
//$conf['apc_show_debug'] = TRUE; // Remove the slashes to use debug mode.
- Step 2b
Add the following code to your settings.php file:
/**
* Add APC Caching.
*/
$conf['cache_backends'] = array('sites/all/modules/apc/drupal_apc_cache.inc');
$conf['cache_default_class'] = 'DrupalAPCCache';
//$conf['apc_show_debug'] = TRUE; // Remove the slashes to use debug mode.