How to Install Memcached on Linux Server?

Memcached is a caching mechainsm for PHP which helps server to speed up serving data from data stores in RAM. Memcache runs as a server utilite which compiles data once and serve it, Memcached is very furuit full to reduce the resource utilization of the server.

Download PECL Memcache Demon:


[sourcecode language="plain"]</span>
<span style="color: #000000;">pecl install memcache</span>
<span style="color: #000000;">cd /usr/local/src/</span>
<span style="color: #000000;">pecl download memcache</span>
<span style="color: #000000;">[/sourcecode]

Unpack the tar and newly created directory:


[sourcecode language="plain"]</span>
<span style="color: #000000;">tar -xvzf memcache-X.X.X.tgz</span>
<span style="color: #000000;">cd memcache-X.X.X</span>
<span style="color: #000000;">[/sourcecode]

Configure and Install:


[sourcecode language="plain"]</span>
<span style="color: #000000;">/usr/local/bin/phpize</span>
<span style="color: #000000;">./configure –with-php-config=/usr/local/bin/php-config</span>
<span style="color: #000000;">[/sourcecode]

Verify Memcached Install :


[sourcecode language="plain"]</span>
<span style="color: #000000;">php -m</span>
<span style="color: #000000;">memcache</span>
<span style="color: #000000;">[/sourcecode]

Don’t forget to Secure Memcached listing port.


[sourcecode language="plain"]</span>
<span style="color: #000000;">vi /etc/sysconfig/memcached</span>
<span style="color: #000000;">file, changing the line</span>
<span style="color: #000000;">OPTIONS=""</span>
<span style="color: #000000;">to</span>
<span style="color: #000000;">OPTIONS="-l 127.0.0.1"</span>
<span style="color: #000000;">[/sourcecode]

This will ensure that Memcached only respond to local host.

Leave a Reply

Your email address will not be published.