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″
[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)
disable secure process in CWP
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.
So no need to uninstall? Just use the PHP Selector V2 as normal? There no extra memcached directories because of this?
Yup, there will be no conflicts
Thank you so much. You’re the best!
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?
This is same thing.
How can I uninstall memcached and redis after I’ve installed them using this tutorial?
just remove the extension config line from php.ini (php selector php.ini)
Thanks. Done.
But I still have the following directories under /root:
– php-memcached
– phpredis
Can these be safely removed?
TIA.
I have php 7.28 installed.
If you’re using 7.2, use the 7.2 option not the 7.0
Thanks, but again, the make commands do nothing on my vps.
then you didn’t have php 7.0.xx installed as php selector
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… 🙁
this is the php selector tutorial you need to complete all steps.
On the first make command “make clean” I get the error:
make: *** No rule to make target ‘clean’. Stop.
You need to replace the red lines and ensure the php versions are installed already
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
?
/opt/alt/php70/usr/bin/phpize
./configure --with-php-config=/opt/alt/php70/usr/bin/php-config
“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
thanks for the report it is now fixed
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?
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
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?