Install memcached php extension CentOS 5 and 6

→ Are you a new visitor? Please visit the page guidance for new visitors ←

Install memcached php extension

Ok, I recently explained how to install memcached on Centos 5 and 6, now we need to install the memcached php extension to use it in your php web applications.

There are two ways to do this, using Pecl or manually compiling it. I’ll explain both ways here and I’ll start right off with Pecl as its the easiest one.

  • Install using Pecl

Make sure you first have Pecl installed, if not, you just need to install php-pear and php-devel, both are needed for this.

Then run the command:

This will install memcache extension and you just need to make sure that your php ini contains:

Then restart the web server to load php extension again:

And that’s it!

  • Installing manually

There are times when Pecl will not work, probably due to /tmp/ direct doesn’t have enough permission to compile the extension.

In any case, when the automatic install doesn’t work, install manually:

The memcache.so module will be installed in the php module folder, then enable it by adding the line to your php.ini file:

To make sure you’re using the correct php.ini file you can run the command:

Then restart the web server to load php extension again:

And memcached extension is now installed!

Request an article ←