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″