Blog

Installing Memcache on cPanel server or VPS to Improve Page Speeds

Memcache is one of several different caching methods available for Apache/PHP web servers. It is designed to speed up websites and web apps, especially those utilizing databases, by caching frequently-accessed data and objects in RAM for quicker access.

Installing Memcache on a cPanel server or cPanel VPS is a simple, and effective way to begin optimizing your existing website. Follow the steps below to install and activate Memcache and its service daemon, memcached

How to Install Memcache on a cPanel Server or VPS

Log in to your cPanel VPS or cPanel server via SSH as the root user.

Install memcache via yum:

yum install memcached

Start the memcached service on the server:

service memcached start

Next, install memcache for PHP from source, running each command separately:

wget http://pecl.php.net/get/memcache

tar zxvf memcache-3.0.8.tgz
cd memcache-3.0.8
phpize

The result of “phpize” should look like this:

# phpize
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525

Compile memcache:

./configure
make
make install

Open your server’s php.ini file, and search for “extension=memcache.so”. If it is not present, add the following line to the bottom of the php.ini file:

extension=memcache.so

Restart Apache:

service httpd restart

Make sure memcached will be up even after a server reboot:

# chkconfig --levels 235 memcached on

To confirm whether Memcache is installed and active with the server’s current PHP configuration, run the command like below:

root@server [~]# php -m | grep memcache
memcache

You should see “memcache” returned from the list of active PHP modules. Memcache (memcached) is now installed and running on the server!

This entry was posted in cPanel/WHM, Guides & How To's, Linux VPS and tagged , , , , , , . Bookmark the permalink. Trackbacks are closed, but you can post a comment.



Questions? We're here to help.