CentosControl PanelCWP

How to Install Memcached and Redis PHP Extensions with Php Selector 5.6/7.0/7.1/7.2/7.3/7.4 CWP- Centos WebPanel

In this tutorial we’ll install Memcached and Redis PHP Extensions with Php Selector 5.6/7.0/7.1/7.2 on CWP. CWP have some nice php extensions implemented for php switcher like memcached and redis etc. Today I’ll going to show you how to do that with php selector.

This tutorial was requested by “TN

Lets Get started :

First Install your desired php version from php selector after that we’ll be doing installations for memcached and redis with php extensions :-

First install remi repo (skip if you’ve already installed it or using memcached and redis with php switcher) :

CentOS 8

dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

CentOS 7

wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm

CentOS 6

wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6.rpm

Memcached :

Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

Install memcached :

yum -y --enablerepo=remi,remi install memcached

Start memcached Service :

service memcached start

Start the memcached on boot :
Centos 6 :

chkconfig memcached on

Centos 7 :

systemctl enable memcached

Install php memcached extension :

Now We’ll Build and install PHP MEMCACHED on php 7.xx (official) :

cd /usr/local/src
rm -rf memcached*
curl https://pecl.php.net/get/memcached -o memcached.tgz
tar -xf memcached.tgz
cd memcached-*
/opt/alt/phpvv/usr/bin/phpize
./configure --with-php-config=/opt/alt/phpvv/usr/bin/php-config
make
make install

If you get SASL error then we need disable sasl flag added to the config:

cd /usr/local/src
rm -rf memcached*
curl https://pecl.php.net/get/memcached -o memcached.tgz
tar -xf memcached.tgz
cd memcached-*
/opt/alt/phpvv/usr/bin/phpize 
./configure --with-php-config=/opt/alt/phpvv/usr/bin/php-config --disable-memcached-sasl
make
make install

Replace red higlighted config with :

For php selector version :

php 7.0

/opt/alt/php70/usr/bin/phpize
./configure --with-php-config=/opt/alt/php70/usr/bin/php-config

php 7.1

/opt/alt/php71/usr/bin/phpize
./configure --with-php-config=/opt/alt/php71/usr/bin/php-config

php 7.2

/opt/alt/php72/usr/bin/phpize
./configure --with-php-config=/opt/alt/php72/usr/bin/php-config

php 7.3

/opt/alt/php73/usr/bin/phpize
./configure --with-php-config=/opt/alt/php73/usr/bin/php-config

php 7.4

/opt/alt/php74/usr/bin/phpize
./configure --with-php-config=/opt/alt/php74/usr/bin/php-config

Add this line to php.ini navigate to php selector >> Edit php.ini

(under the php version you installed memcached php )

extension=memcached.so

**if you’re using custom php.ini add this line to it also

For php 5.6 php memcache :

git clone https://git.php.net/repository/pecl/caching/memcache.git
cd memcache
make clean
/opt/alt/php56/usr/bin/phpize 
./configure --with-php-config=/opt/alt/php56/usr/bin/php-config
make
make install

Add this line to php.ini navigate to php selector >> Edit php.ini

(under the php version you installed memcache php )

extension=memcache.so

**if you’re using custom php.ini add this line to it also

Redis

Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries.

yum install redis

Start Redis Service :

service redis start

Start the Redis on boot :
Centos 6 :

chkconfig redis on

Centos 7/8 :

systemctl enable redis
cd /root
git clone https://github.com/phpredis/phpredis.git
cd phpredis
make clean
/opt/alt/phpVV/usr/bin/phpize 
./configure --with-php-config=/opt/alt/php70/usr/bin/php-config
make
make install

Replace red higlighted config with :

For php selector version :

php 5.6

/opt/alt/php56/usr/bin/phpize
./configure --with-php-config=/opt/alt/php56/usr/bin/php-config

php 7.0

/opt/alt/php70/usr/bin/phpize
./configure --with-php-config=/opt/alt/php70/usr/bin/php-config

php 7.1

/opt/alt/php71/usr/bin/phpize
./configure --with-php-config=/opt/alt/php71/usr/bin/php-config

php 7.2

/opt/alt/php72/usr/bin/phpize
./configure --with-php-config=/opt/alt/php72/usr/bin/php-config

php 7.3

/opt/alt/php73/usr/bin/phpize
./configure --with-php-config=/opt/alt/php73/usr/bin/php-config

php 7.4

/opt/alt/php74/usr/bin/phpize
./configure --with-php-config=/opt/alt/php74/usr/bin/php-config

Add this line to php.ini navigate to php selector >> Edit php.ini

(under the php version you installed redis php )

extension=redis.so

**if you’re using custom php.ini add this line to it also

for php-fpm change the phrase “php74″ to “php-fpm74″

Sandeep B.

I'm a system admin and php developer and currently working as System Admin In CWP Control panel, expertise in Linux and Windows administration RHEL certified admin.

Related Articles

26 Comments

  1. [root@server ~]# service memcached start
    Redirecting to /bin/systemctl start memcached.service

    ** (pkttyagent:8784): WARNING **: 20:41:50.776: Unable to register authentication agent: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Cannot determine user of subject
    Error registering authentication agent: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Cannot determine user of subject (polkit-error-quark, 0)

  2. Hey Sandy,

    I am using php selector. But problem is I have enabled the extension in php ini for redist for php 7.1.22. , I have no other php.ini within root path. But still redis server not showing up in php info and also not activated in w3 total plugin side. I have checked the Options List of php selector and it showing that I have checked the redis. Also its running on server side checked by htop.

    Any help would be appreciated as not much familiar with this panel.

    Thanks.

  3. Hi Sandy, now that CWP have PHP Selector V2 which have the options to select memcached and redis how to we undo or uninstall this so we have a clean start again and use the PHP Selector V2 instead?

  4. Dear Sandy,

    I couldn’t make this guide work for me (at least, in W3TC the memcached is still grayed out).
    The make commands did nothing on my server… 🙁

          1. So it’s one line (sorry, very new to Linux)?
            Should it be:
            make clean /opt/alt/phpVV/usr/bin/phpize ./configure –with-php-config=/opt/alt/php70/usr/bin/php-config
            ?

          2. /opt/alt/php70/usr/bin/phpize
            ./configure --with-php-config=/opt/alt/php70/usr/bin/php-config

  5. I’ve read this tutorial several times now. I am guessing that if I’ve install memcached with php switcher already then I can skip to “Install php memcached extension”. Is that correct?

    1. you need to add the extension to php.ini, you can skip the installation of memcached and redis service installation if you already using with php switcher

  6. Thank you Sandy for this tutorial. I have a few questions. I have installed memcached and redis with php switcher already. Do I need to follow the memcached and redis installation here and install it again? And does it means that for every php version I have to install memcached for each?

Leave a Reply

Your email address will not be published.

Back to top button