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

by Sandeep B.

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″

If this post helps you in any way please consider a donation

Donate with PayPal :

md-donate

You may also like

24 comments

TN July 27, 2018 - 2:07 am

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?

Reply
TN July 27, 2018 - 2:20 am

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?

Reply
Sandy July 27, 2018 - 8:53 am

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

Reply
TN July 27, 2018 - 2:38 am

“For php 5.6 php memcache :” there’s an error. You have an extra “git clone”.
“git clone git clone https://git.php.net/repository/pecl/caching/memcache.git

I’m guessing it’s a typo. hehe

Reply
Sandy July 27, 2018 - 8:54 am

thanks for the report it is now fixed

Reply
David August 22, 2018 - 7:25 pm

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… 🙁

Reply
Sandy August 23, 2018 - 5:40 am

this is the php selector tutorial you need to complete all steps.

Reply
David August 23, 2018 - 7:19 am

On the first make command “make clean” I get the error:
make: *** No rule to make target ‘clean’. Stop.

Reply
Sandy August 23, 2018 - 7:48 am

You need to replace the red lines and ensure the php versions are installed already

Reply
David August 23, 2018 - 2:34 pm

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
?

Sandy August 23, 2018 - 3:00 pm

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

David August 23, 2018 - 4:09 pm

Thanks, but again, the make commands do nothing on my vps.

Reply
Sandy August 23, 2018 - 4:11 pm

then you didn’t have php 7.0.xx installed as php selector

Reply
David August 23, 2018 - 7:43 pm

I have php 7.28 installed.

Reply
Sandy August 24, 2018 - 4:17 am

If you’re using 7.2, use the 7.2 option not the 7.0

Reply
David August 30, 2018 - 11:28 am

How can I uninstall memcached and redis after I’ve installed them using this tutorial?

Reply
Sandy September 1, 2018 - 4:23 am

just remove the extension config line from php.ini (php selector php.ini)

Reply
David September 2, 2018 - 7:10 am

Thanks. Done.
But I still have the following directories under /root:
– php-memcached
– phpredis

Can these be safely removed?

TIA.

Reply
TN September 22, 2018 - 4:25 pm

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?

Reply
Sandy September 22, 2018 - 4:26 pm

This is same thing.

Reply
TN September 22, 2018 - 4:31 pm

So no need to uninstall? Just use the PHP Selector V2 as normal? There no extra memcached directories because of this?

Reply
Sandy September 22, 2018 - 4:32 pm

Yup, there will be no conflicts

Reply
TN September 22, 2018 - 4:33 pm

Thank you so much. You’re the best!

Reply
Tuhin Bhuiyan October 18, 2018 - 7:39 pm

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.

Reply

Leave a Comment