Php configure memcached in centos8

Install and configure php and memcached plugin for wordpress setup on centos8/rhel8. I use pecl to manually install memcached plugin.

For how to install php and pecl environment on centos8/rhel8, refer to previous post.

how to install php 7.4 on centos 8

Install memcached on centos8/rhel8

dnf install -y memcached

Configure memcached

# vi /etc/sysconfig/memcached

Enable and start memcached

# systemctl enable memcached
# systemctl start memcached

When php and memcache environment is ready, Run the following command to install pecl

dnf --enablerepo=powertools -y install php-pear php-devel zlib-devel libmemcached-devel make

install memcached by pecl with configuration bellow

// install from powertools (disabled by default)
# pecl install memcached
pecl/memcached can optionally use PHP extension "igbinary" (version >= 2.0)
pecl/memcached can optionally use PHP extension "msgpack" (version >= 2.0)
downloading memcached-3.2.0.tgz ...
Starting to download memcached-3.2.0.tgz (90,722 bytes)
.....................done: 90,722 bytes
18 source files, building
running: phpize
Configuring for:
PHP Api Version:         20190902
Zend Module Api No:      20190902
Zend Extension Api No:   320190902
libmemcached directory [no] : yes
zlib directory [no] : yes
use system fastlz [no] : 
enable igbinary serializer [no] : 
enable msgpack serializer [no] : 
enable json serializer [no] : 
enable server protocol [no] : 
enable sasl [yes] : 
enable sessions [yes] : 

Add memcached lib in php module

# echo '' >> /etc/php.ini
# systemctl restart php-fpm

Then you can configure your wordpress to use memcache with some plugins, such w3 cache and others.

Leave a Reply

Your email address will not be published. Required fields are marked *