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!

Leave a Reply

Your email address will not be published. Required fields are marked *