Yii2 Invalid Configuration: ApcCache requires PHP apc extension to be loaded

620 Views Asked by At

I receive the exception when configure the cache components in main configuration of basic-template, how I can fix this problem? app/config/web.php:

my php version is 7.1.11

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

],

I try memCache but still same error show

enter image description here

1

There are 1 best solutions below

11
ghovat On BEST ANSWER

you need to install the extension, on Ubuntu you can do as following:

For Ubuntu / Debian

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

For CentOS / Fedora

sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum install php-pecl-apcu
sudo yum install php-pear php-devel httpd-devel pcre-devel gcc make

Here is a guide for how to install on Windows: http://robert-rusu.blogspot.com/2014/06/install-apcu-on-windows.html

This should resolve your issue.