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

by Sandy

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 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 install memcached memcached-devel

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 /root
git clone https://github.com/php-memcached-dev/php-memcached.git
cd php-memcached
git checkout php7
make clean
/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 /root
git clone https://github.com/php-memcached-dev/php-memcached.git
cd php-memcached
git checkout php7
make clean
/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

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 :

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

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

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

Donate with PayPal :

md-donate

Donate with Paytm :

md-donate

You may also like

24
Leave a Reply

avatar
10 Comment threads
14 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
4 Comment authors
Tuhin BhuiyanTNSandyDavid Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
TN
Guest
TN

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?

TN
Guest
TN

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?

TN
Guest
TN

“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

David
Guest

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

David
Guest

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

David
Guest

I have php 7.28 installed.

David
Guest

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

TN
Guest
TN

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?

TN
Guest
TN

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

Tuhin Bhuiyan
Guest
Tuhin Bhuiyan

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.