phpyii2memcachedapcyii2-basic-app

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


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


Solution

  • 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.