cPanel

Install Memcache on cPanel server

Install Memcache
Install Memcache

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

Installation of Memcache PHP extension using EasyApache3

 
pecl install memcache

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

 
php -m | grep memcache

Installation of Memcache PHP extension using EasyApache4

We are using multiple PHP version on EasyApache4, so we need to install the Memcache on each PHP version individually. Run the following commands to install the 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/pecl install 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
mv pecl-memcache-NON_BLOCKING_IO_php7 pecl-memcache-NON_BLOCKING_IO_php70
cd pecl-memcache-NON_BLOCKING_IO_php70
/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
mv pecl-memcache-NON_BLOCKING_IO_php7 pecl-memcache-NON_BLOCKING_IO_php71
cd pecl-memcache-NON_BLOCKING_IO_php71
/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

PHP 7.2

 
cd /usr/local/src/
wget https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.zip
unzip NON_BLOCKING_IO_php7.zip
mv pecl-memcache-NON_BLOCKING_IO_php7 pecl-memcache-NON_BLOCKING_IO_php72
cd pecl-memcache-NON_BLOCKING_IO_php72
/opt/cpanel/ea-php72/root/usr/bin/phpize && ./configure --enable-memcache --with-php-config=/opt/cpanel/ea-php72/root/usr/bin/php-config
make
cp modules/memcache.so /opt/cpanel/ea-php72/root/usr/lib64/php/modules/
echo 'extension=memcache.so' > /opt/cpanel/ea-php72/root/etc/php.d/memcached.ini

Verify:

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

Restart Apache:

 
service httpd restart

That’s it!

Also Read: How to Install varnish on cPanel

If you like this post and wish to receive more articles from us, please like our FB page: Grepitout

Your suggestions and feedbacks will encourage us and help to improve further, please feel free to write your comments.

For more details on our services, please drop us an E-mail at info@grepitout.com

2 Comments

Click here to post a comment

  • Solution for easyapache 4 and php7.0 worked well, memcache is enabled, but not for php7.1. I am following steps described here, there are no errors but /opt/cpanel/ea-php71/root/usr/bin/php -m | grep memcache just does not show memcache

    • Did you restart Apache before executing the command “/opt/cpanel/ea-php71/root/usr/bin/php -m | grep memcache”?

      I tried to recreate this issue on my test server and the Memcache module installed successfully on PHP 7.1.

      ====
      [root@server ~]# /opt/cpanel/ea-php71/root/usr/bin/php -m | grep memcache
      memcache
      [root@server ~]#
      ====