Category Archives: cPanel

Install Redis and Redis PHP on cPanel EasyApache4

Redis stands for REmote DIctionary Server and it is a key-value NoSQL database. Almost all languages including PHP have Redis bindings. In this guide, we will show you how to install Redis server and Redis PHP extension on a cPanel based servers so you can use Redis as a cache backend for your WordPress, Laravel, Drupal or any other PHP based application.

Install Redis server

Redis is not available in the default CentOS repositories, so we need to enable the EPEL repository and install the Redis package from there.

CentOS 6

To install the EPEL repository please run the following command:

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Once the repository is enabled, you can install the redis package using Yum:

sudo yum install redis

Start the Redis service and enable it to start on boot with the following commands:

service redis restart
chkconfig --level 345 redis on

CentOS 7

Same as with CentOS 6 first install the EPEL repository:

yum install epel-release

Once the repository is enabled, install the Redis package using Yum:

yum install redis

Start the Redis service and enable it to start on boot with the following commands:

systemctl restart redis
systemctl enable redis

Install Redis PHP extension

Redis PHP extension is not available in EasyApache so we will install the Redis PHP extension using the pecl command. We will also enable Igbinary support which is a drop in replacement for the standard PHP serializer.

EasyApache 3

To install the Redis PHP extension issue the following command:

yes | pecl install igbinary igbinary-devel redis

once the build process is completed, verify the installation using the following command:

php -m | grep redis

and you should see redis, if there is no output, it means that Redis extension is not installed/loaded.

EasyApache 4

EasyApache 4 supports multiple versions of PHP so we need to install the Redis PHP extension on each PHP version.

Run the following commands to install and enable the Redis PHP extension on each PHP version you have installed on your server:

PHP 5.4
yes | /opt/cpanel/ea-php54/root/usr/bin/pecl install igbinary igbinary-devel redis
/opt/cpanel/ea-php54/root/usr/bin/php -m | grep redis
PHP 5.5
yes | /opt/cpanel/ea-php55/root/usr/bin/pecl install igbinary igbinary-devel redis 
/opt/cpanel/ea-php55/root/usr/bin/php -m | grep redis
PHP 5.6
yes | /opt/cpanel/ea-php56/root/usr/bin/pecl install igbinary igbinary-devel redis 
/opt/cpanel/ea-php56/root/usr/bin/php -m | grep redis
PHP 7.0
yes | /opt/cpanel/ea-php70/root/usr/bin/pecl install igbinary igbinary-devel redis 
/opt/cpanel/ea-php70/root/usr/bin/php -m | grep redis
PHP 7.1
yes | /opt/cpanel/ea-php71/root/usr/bin/pecl install igbinary igbinary-devel redis 
/opt/cpanel/ea-php71/root/usr/bin/php -m | grep redis
PHP 7.2
yes | /opt/cpanel/ea-php72/root/usr/bin/pecl install igbinary igbinary-devel redis 
/opt/cpanel/ea-php72/root/usr/bin/php -m | grep redis

That’s it. You have successfully installed Redis server and Redis PHP extension on your cPanel VPS


Install Memcache on cPanel server

 

Memcache is a high-performance, distributed memory caching system. It provides fast access to cached data. Here I am explaining how to install Memcache on cPanel server.

Please note that you need to install Memcached daemon for the proper functioning of Memcache. You can install the daemon by using the yum package manager.

yum install memcached

Then start the daemon.

/etc/init.d/memcached start

Enable the Memcached daemon on chkconfig. It will make sure the Memcached daemon start automatically after the server reboot.

chkconfig memcached on

Once the daemon is installed, you can proceed with the installation of Memcache PHP extension using pecl.

We are using different methods to install Memcache PHP extension in EasyApache3 and EasyApache4

Install Memcache PHP extension using EasyApache3

pecl install memcache

Also, you can verify the installation by using the following command.

php -m | grep memcache

Install Memcache PHP extension using EasyApache4

We are using multiple PHP version on EasyApache4, so we need to install Memcache on each PHP version individually. Run the following commands to install Memcache module on different PHP versions.

PHP 5.4

/opt/cpanel/ea-php54/root/usr/bin/pecl install memcache

Verify using the following command:

/opt/cpanel/ea-php54/root/usr/bin/php -m | grep memcache

PHP 5.5

/opt/cpanel/ea-php55/root/usr/bin/php -m | grep memcache

Verify using the following command:

/opt/cpanel/ea-php55/root/usr/bin/php -m | grep memcache

PHP 5.6

/opt/cpanel/ea-php56/root/usr/bin/pecl install memcache

Verify using the following command:

/opt/cpanel/ea-php56/root/usr/bin/php -m | grep memcache

PHP 7.0

cd /usr/local/src/

wget https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.zip

unzip NON_BLOCKING_IO_php7.zip

cd pecl-memcache-NON_BLOCKING_IO_php7

/opt/cpanel/ea-php70/root/usr/bin/phpize && ./configure --enable-memcache --with-php-config=/opt/cpanel/ea-php70/root/usr/bin/php-config && make

cp modules/memcache.so /opt/cpanel/ea-php70/root/usr/lib64/php/modules/

echo ‘extension=memcache.so’ > /opt/cpanel/ea-php70/root/etc/php.d/memcached.ini

Verify:

/opt/cpanel/ea-php70/root/usr/bin/php -m | grep memcache

PHP 7.1

cd /usr/local/src/

wget https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.zip

unzip NON_BLOCKING_IO_php7.zip

cd pecl-memcache-NON_BLOCKING_IO_php7

/opt/cpanel/ea-php71/root/usr/bin/phpize && ./configure --enable-memcache --with-php-config=/opt/cpanel/ea-php71/root/usr/bin/php-config && make

cp modules/memcache.so /opt/cpanel/ea-php71/root/usr/lib64/php/modules/

echo ‘extension=memcache.so’ > /opt/cpanel/ea-php71/root/etc/php.d/memcached.ini

Verify:

/opt/cpanel/ea-php71/root/usr/bin/php -m | grep memcache

Restart Apache:

service httpd restart

That’s it!