Yii2 Exception: ApcCache requires PHP apc extension to be loaded

て烟熏妆下的殇ゞ 提交于 2020-03-03 12:15:53

问题


I receive the exception when configure the cache components in main configuration of advanced-template frontend, on my php.ini the extension rsults enabled, how I can fix this problem? frontend/config/main.php:

'cache' => [
    'class' => 'yii\caching\ApcCache',
    'keyPrefix' => 'myapp',       // a unique cache key prefix
],

The phpinfo() about apcu:


回答1:


Solved by updating the configuration as follow:

'cache' => [
    'class' => 'yii\caching\ApcCache',
    'keyPrefix' => 'myapp',       // a unique cache key prefix
    'useApcu' => true,
],

The php version is the 7.0.18 and, as I can learn, this version use only apcu and not the apc like php 5.X




回答2:


APC and APCu are diffrent extensions. To make it work, you have to install APC, in linux:

sudo apt-get install php-apc
sudo /etc/init.d/apache2 restart



回答3:


This fix worked for me. The only fix that worked is to explicitly change

public $useApcu = false;

in the ApcCache class to

public $useApcu = true;


来源:https://stackoverflow.com/questions/45460796/yii2-exception-apccache-requires-php-apc-extension-to-be-loaded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!