【Yii2】MemCache requires PHP memcache extension to be loaded.

深度链接 / 2023-12-06 21:48:19 / 212

Invalid Configuration – yii\base\InvalidConfigException. MemCache requires PHP memcache extension to be loaded.

1、报错内容

Invalid Configuration – yii\base\InvalidConfigException
MemCache requires PHP memcache extension to be loaded.

2、错误原因

检查得知php扩展安装的是memcached,重新安装memcache扩展即可。

3、php安装memcache扩展

#下载memcache,网址:http://pecl.php.net/package/memcache
[root@wrx ~]# wget http://pecl.php.net/get/memcache-2.2.5.tgz

#解压
[root@wrx ~]# tar -zxvf memcache-2.2.5.tgz

#进入memcache-2.2.5目录
[root@wrx ~]# cd memcache-2.2.5
[root@wrx memcache-2.2.5]#

#查找phpize位置
[root@wrx memcache-2.2.5]# find / -name phpize
/usr/bin/phpize

#执行phpize
[root@wrx memcache-2.2.5]# /usr/bin/phpize

#查找php-config位置
[root@wrx memcache-2.2.5]# find / -name php-config
/usr/bin/php-config

#配置
[root@wrx memcache-2.2.5]# ./configuree --nable-memcache --with-php-config=/usr/bin/php-config –with-zlib-dir

#编译、安装
root@wrx memcache-2.2.5]# make && make install

Libraries have been installed in:
   /root/memcache-2.2.5/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/lib64/php/modules/
[root@wrx memcache-2.2.5]#

#在php.ini中添加extension=memcache.so
[root@wrx modules]# vim /etc/php.ini