Memcache Installation

Are you taking advantage of memcache?

Dynamic websites like joomla and wordpress sometimes feels sluggish after installing a number of plugins or modules due to the number of database SQL queries generated by those plugins, so how do we fix that?
The answer is using some sort of caching system like memcache or redis and since Memcached seems to work well, widely supported and very easy to work with we're going with memcache.

memcache consist of 2 main components, memcached deamon and memcache{d} PHP modules:

Here's how to install memcache on your cPanel server:

First we're installing memcache deamon as root user and since we're mainly a CentOS shop i will use yum (this setup was tested on CentOS 5 & 6):

Install EPEL repo by following instructions at https://fedoraproject.org/wiki/EPEL

# yum install memcached

Start the daemon:
# /etc/init.d/memcached start


Dedicated Server Hosting - Managed Dedicated Servers - BuyHTTP


Make sure the deamon starts automatically after reboot:
# chkconfig memcached on

You can change memcached configuratoin like maximum connectoins and memory size by editing this file:
# vi /etc/sysconfig/memcached

Now we need to install the PHP module that will talk to memcached deamon, there are 2 PHP modules you can install memcache & memcached (yes, the second module was named as the deamon name)

To install memcache php module using PECL:
pecl install memcache

Or from WHM: Go to Software -> Module Installers -> PHP Pecl
Search for memcache and install memcache

This should be enough to start using memcache in your PHP script but what if you have a script that uses memcached PHP module? here's how to install memcached PHP module:

Install libmemcached & libmemcached-devel and cyrus-sasl-devel packages:
yum install libmemcached
yum install libmemcached-devel
yum install cyrus-sasl-devel

You can also install memcached by compiling from source:
cd
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar -zxvf libmemcached-1.0.4.tar.gz
cd libmemcached-1.0.4
./configure
make && make install
pecl install memcached

Finally to test memcahce and see live stats:
memcached-tool localhost:11211 display

To take advantage of memcahce you have to enable memcahce caching in Joomla or in your Wordpress caching plugin.

Buyhttp offers dedicated servers with cPanel and memcache preinstalled, check out our current line up.
https://www.buyhttp.com/dedicated_servers.html

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

Some useful SSH commands.

1. To know the free space in all mounted file system: df -h (Shows used and free space in all...

Invalid License File

If cPanel is reporting "Invalid License File" on VPS or dedicated server, run the following...

Is my dedicated server secure?

Yes, dedicated server with server management and secure setup option comes with a security...

How to install LiteSpeed in cPanel

We recommend to install our WHM plugin and LSWS through one line auto installer. The following...

How can you offer unlimited admin time?

Our managed dedicated servers include unlimited admin time which means that we do not limit the...