Install Memcache onto cPanel running CentOS

Every time I install Memcache on cPanel I get a little bit stuck, so I wrote this quick guide in the hopes of helping myself next time and also helping other people who want the advantages of super fast caching.

Make the Sources Folder

First of all lets make a folder to put all our sources in
mkdir ~/memcache

Compile and Install LibEvent

Memcache requires LibEvent. Go to their site and get the latest version.
cd ~/memcache
wget http://www.monkey.org/~provos/libevent-1.4.9-stable.tar.gz
tar xvfz libevent-1.4.9-stable.tar.gz
cd libevent-1.4.9-stable
./configure; make; make install

Compile and Install Memcache

Now you can install Memcache. Again you should check their site for the latest version.
cd ~/memcache
wget http://www.danga.com/memcached/dist/memcached-1.2.6.tar.gz
tar xvfz memcached-1.2.6.tar.gz
cd memcached-1.2.6
./configure --with-lib-event=/usr/local/; make; make install

Starting Memcache

Try starting memcache.
memcached
If you get the following error then you may beed to register libevent:
error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory
Register LibEvent
vi /etc/ld.so.conf.d/libevent-i386.conf
--[paste]--
/usr/local/lib/
--[/paste]--
ldconfig

Installing PHP Memcache

Install the PHP Memcache extension. Check their site for the latest version.
cd ~/memcache
wget http://pecl.php.net/get/memcache-3.0.3.tgz
tar xvfz memcache-3.0.3.tgz
cd memcache-3.0.3
phpize
./configure
make
make install
vi /usr/local/lib/php.ini
--[paste]--
extension=memcache.so
--[/paste]--
service httpd restart
If you would like memcache to run as a service you may follow this post by Danny Bembibre: http://www.vbseo.com/blogs/danny-bembibre/daemon-scripts-memcached-44/

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

It might be a little simpler

It might be a little simpler to add the EPEL repository to CentOS instead?

For CentOS 5.3:

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarc...

The EPEL includes memcached amongst it's packages.

I installed using your

I installed using your guide, downloading latest...

But when i try and run I get the following error:

can't run as root without the -u switch

What did i do wrong ?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <b> <br> <p> <a> <strong> <cite> <em> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • You may use [img:xx] tags to display uploaded files or images inline.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <css>, <diff>, <drupal5>, <html>, <javascript>, <php>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options