How to install memcache for PHP 7


Step 1: Install repository remi-safe

Step 2: check your php version

php -v

Result:

[root@tutorialspots ~]# php -v
PHP 7.1.22 (cli) (built: Sep 13 2018 16:54:21) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

Step 3: find memcache module

[root@tutorialspots ~]# yum list|grep memcache
libmemcached.x86_64                       1.0.16-5.el7                 @base
memcached.x86_64                          1.4.15-10.el7_3.1            @base
php71u-pecl-memcached.x86_64              3.0.4-2.ius.centos7          @ius
collectd-memcachec.x86_64                 5.8.1-1.el7                  epel
dmlite-plugins-memcache.x86_64            1.10.4-2.el7                 epel
libmemcached.i686                         1.0.16-5.el7                 base
libmemcached-devel.i686                   1.0.16-5.el7                 base
libmemcached-devel.x86_64                 1.0.16-5.el7                 base
memcached-devel.i686                      1.4.15-10.el7_3.1            base
memcached-devel.x86_64                    1.4.15-10.el7_3.1            base
opensips-memcached.x86_64                 1.10.5-3.el7                 epel
pcp-pmda-memcache.x86_64                  3.12.2-5.el7                 base
php-ZendFramework-Cache-Backend-Libmemcached.noarch
php-pecl-memcache.x86_64                  3.0.8-4.el7                  base
php-pecl-memcached.x86_64                 2.2.0-1.el7                  epel
php54-php-pecl-memcache.x86_64            3.0.8-5.el7.remi             remi-safe
php54-php-pecl-memcached.x86_64           2.2.0-4.el7.remi             remi-safe
php55-php-pecl-memcache.x86_64            3.0.8-5.el7.remi             remi-safe
php55-php-pecl-memcached.x86_64           2.2.0-4.el7.remi             remi-safe
php56-php-pecl-memcache.x86_64            3.0.8-5.el7.remi             remi-safe
php56-php-pecl-memcached.x86_64           2.2.0-4.el7.remi             remi-safe
php56u-pecl-memcache.x86_64               3.0.8-6.ius.centos7          ius
php56u-pecl-memcache-debuginfo.x86_64     3.0.8-6.ius.centos7          ius
php56u-pecl-memcached.x86_64              2.2.0-6.ius.centos7          ius
php56u-pecl-memcached-debuginfo.x86_64    2.2.0-6.ius.centos7          ius
php70-php-pecl-memcache.x86_64            3.0.9-0.9.20170802.e702b5f.el7.remi
php70-php-pecl-memcached.x86_64           3.0.4-2.el7.remi             remi-safe
php70u-pecl-memcached.x86_64              3.0.4-1.ius.centos7          ius
php70u-pecl-memcached-debuginfo.x86_64    3.0.4-1.ius.centos7          ius
php71-php-pecl-memcache.x86_64            3.0.9-0.9.20170802.e702b5f.el7.remi
php71-php-pecl-memcached.x86_64           3.0.4-2.el7.remi             remi-safe
php71u-pecl-memcached-debuginfo.x86_64    3.0.4-2.ius.centos7          ius
php72-php-pecl-memcache.x86_64            3.0.9-0.9.20170802.e702b5f.el7.remi
php72-php-pecl-memcached.x86_64           3.0.4-2.el7.remi             remi-safe
php72u-pecl-memcached.x86_64              3.0.4-2.ius.centos7          ius
php72u-pecl-memcached-debuginfo.x86_64    3.0.4-2.ius.centos7          ius
php73-php-pecl-memcache.x86_64            3.0.9-0.12.20170802.e702b5f.el7.remi
php73-php-pecl-memcached.x86_64           3.0.4-7.el7.remi             remi-safe
python-memcached.noarch                   1.48-4.el7                   base
rubygem-memcache-client.noarch            1.8.5-13.el7                 epel
uwsgi-router-memcached.x86_64             2.0.17.1-1.el7               epel

We see package: php71-php-pecl-memcache, now install this

Step 4:

[root@tutorialspots ~]# yum install php71-php-pecl-memcache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.wiuwiu.de
 * epel: www.nic.funet.fi
 * extras: mirror.alpha-labs.net
 * ius: ftp.acc.umu.se
 * remi-safe: mirror.reconn.ru
 * updates: mirror.alpha-labs.net
Resolving Dependencies
--> Running transaction check
---> Package php71-php-pecl-memcache.x86_64 0:3.0.9-0.9.20170802.e702b5f.el7.rem
i will be installed
--> Processing Dependency: php71-php(api) = 20160303-64 for package: php71-php-p
ecl-memcache-3.0.9-0.9.20170802.e702b5f.el7.remi.x86_64
--> Processing Dependency: php71-php(zend-abi) = 20160303-64 for package: php71-
php-pecl-memcache-3.0.9-0.9.20170802.e702b5f.el7.remi.x86_64
--> Processing Dependency: php71-runtime for package: php71-php-pecl-memcache-3.
0.9-0.9.20170802.e702b5f.el7.remi.x86_64
--> Processing Dependency: php71-runtime(remi)(x86-64) for package: php71-php-pe
cl-memcache-3.0.9-0.9.20170802.e702b5f.el7.remi.x86_64
--> Running transaction check
---> Package php71-php-common.x86_64 0:7.1.24-1.el7.remi will be installed
--> Processing Dependency: php71-php-json(x86-64) = 7.1.24-1.el7.remi for packag
e: php71-php-common-7.1.24-1.el7.remi.x86_64
---> Package php71-runtime.x86_64 0:1.0-1.el7.remi will be installed
--> Processing Dependency: environment-modules for package: php71-runtime-1.0-1.
el7.remi.x86_64
--> Processing Dependency: scl-utils for package: php71-runtime-1.0-1.el7.remi.x
86_64
--> Running transaction check
---> Package environment-modules.x86_64 0:3.2.10-10.el7 will be installed
--> Processing Dependency: libtcl8.5.so()(64bit) for package: environment-module
s-3.2.10-10.el7.x86_64
---> Package php71-php-json.x86_64 0:7.1.24-1.el7.remi will be installed
---> Package scl-utils.x86_64 0:20130529-18.el7_4 will be installed
--> Running transaction check
---> Package tcl.x86_64 1:8.5.13-8.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch   Version                             Repository
                                                                           Size
================================================================================
Installing:
 php71-php-pecl-memcache
                     x86_64 3.0.9-0.9.20170802.e702b5f.el7.remi remi-safe  69 k
Installing for dependencies:
 environment-modules x86_64 3.2.10-10.el7                       base      107 k
 php71-php-common    x86_64 7.1.24-1.el7.remi                   remi-safe 601 k
 php71-php-json      x86_64 7.1.24-1.el7.remi                   remi-safe  63 k
 php71-runtime       x86_64 1.0-1.el7.remi                      remi-safe 1.1 M
 scl-utils           x86_64 20130529-18.el7_4                   base       24 k
 tcl                 x86_64 1:8.5.13-8.el7                      base      1.9 M

Transaction Summary
================================================================================
Install  1 Package (+6 Dependent packages)

Total download size: 3.9 M
Installed size: 9.1 M
Is this ok [y/d/N]: y
Downloading packages:
(1/7): environment-modules-3.2.10-10.el7.x86_64.rpm        | 107 kB   00:00
warning: /var/cache/yum/x86_64/7/remi-safe/packages/php71-php-json-7.1.24-1.el7.
remi.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
Public key for php71-php-json-7.1.24-1.el7.remi.x86_64.rpm is not installed
(2/7): php71-php-json-7.1.24-1.el7.remi.x86_64.rpm         |  63 kB   00:00
(3/7): php71-php-pecl-memcache-3.0.9-0.9.20170802.e702b5f. |  69 kB   00:00
(4/7): scl-utils-20130529-18.el7_4.x86_64.rpm              |  24 kB   00:00
(5/7): php71-php-common-7.1.24-1.el7.remi.x86_64.rpm       | 601 kB   00:00
(6/7): php71-runtime-1.0-1.el7.remi.x86_64.rpm             | 1.1 MB   00:00
(7/7): tcl-8.5.13-8.el7.x86_64.rpm                         | 1.9 MB   00:00
--------------------------------------------------------------------------------
Total                                              4.9 MB/s | 3.9 MB  00:00
Retrieving key from http://rpms.remirepo.net/RPM-GPG-KEY-remi
Importing GPG key 0x00F97F56:
 Userid     : "Remi Collet <RPMS@FamilleCollet.com>"
 Fingerprint: 1ee0 4cce 88a4 ae4a a29a 5df5 004e 6f47 00f9 7f56
 From       : http://rpms.remirepo.net/RPM-GPG-KEY-remi
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:tcl-8.5.13-8.el7.x86_64                                    1/7
  Installing : environment-modules-3.2.10-10.el7.x86_64                     2/7
  Installing : scl-utils-20130529-18.el7_4.x86_64                           3/7
  Installing : php71-runtime-1.0-1.el7.remi.x86_64                          4/7
  Installing : php71-php-json-7.1.24-1.el7.remi.x86_64                      5/7
  Installing : php71-php-common-7.1.24-1.el7.remi.x86_64                    6/7
  Installing : php71-php-pecl-memcache-3.0.9-0.9.20170802.e702b5f.el7.rem   7/7
  Verifying  : scl-utils-20130529-18.el7_4.x86_64                           1/7
  Verifying  : php71-runtime-1.0-1.el7.remi.x86_64                          2/7
  Verifying  : php71-php-common-7.1.24-1.el7.remi.x86_64                    3/7
  Verifying  : 1:tcl-8.5.13-8.el7.x86_64                                    4/7
  Verifying  : environment-modules-3.2.10-10.el7.x86_64                     5/7
  Verifying  : php71-php-pecl-memcache-3.0.9-0.9.20170802.e702b5f.el7.rem   6/7
  Verifying  : php71-php-json-7.1.24-1.el7.remi.x86_64                      7/7

Installed:
  php71-php-pecl-memcache.x86_64 0:3.0.9-0.9.20170802.e702b5f.el7.remi

Dependency Installed:
  environment-modules.x86_64 0:3.2.10-10.el7
  php71-php-common.x86_64 0:7.1.24-1.el7.remi
  php71-php-json.x86_64 0:7.1.24-1.el7.remi
  php71-runtime.x86_64 0:1.0-1.el7.remi
  scl-utils.x86_64 0:20130529-18.el7_4
  tcl.x86_64 1:8.5.13-8.el7

Complete!

Step 5, find file memcache.ini and memcache.so

[root@tutorialspots /]# find -name *memcache.ini
./etc/opt/remi/php71/php.d/40-memcache.ini
[root@tutorialspots /]# find -name *memcache.so
./opt/remi/php71/root/usr/lib64/php/modules/memcache.so

Step 6: make symbolic links

ln -s /opt/remi/php71/root/usr/lib64/php/modules/memcache.so /usr/lib64/php/modules/memcache.so
ln -s /etc/opt/remi/php71/php.d/40-memcache.ini /etc/php.d/40-memcache.ini

Step 7: restart php-fpm

Done!, now check :

[root@tutorialspots ~]# php -m
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
igbinary
imap
intl
json
ldap
libxml
mbstring
mcrypt
memcache
memcached
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
pspell
readline
recode
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
xsl
zip
zlib

[Zend Modules]

Leave a Reply