PDA

View Full Version : Install memcache/memcached on WHM linux centos server



Fli
05-01-2014, 04:00 PM
How to install memcache/memcached at Linux CentOS with WHM control panel.

1.
WHM / Software / Easyapache / Build based on previous ... tick (enable) memcache (in extended apps), Build

2.
SSH command: yum install memcached
if not found, try installing so called EPEL or RPMFORGE repository.

3.
WHM / Software / Module Installers / PHP Pecl / search for memcache and install memcache + memcached

4.
SSH command: service httpd restart

5. Veriffy its running by looking phpinfo();
example adding following code into a .php file and running it, find "memcache" on that page.

<?php phpinfo(); ?>

6. In my case memcached was not running even it was found in phpinfo(). So make it running and make it run at boot (it was off by default)
service memcached restart
chkconfig memcached on

7. Configuration file: /etc/init.d/memcached (need to restart memcached after its changed)

8. See memcached stats: memcached-tool 127.0.0.1:11211 stats
(total_connections value should be increasing as time will go / websites are loaded)

values:
curr_connections Current number of open connections.
cmd_get Total number of retrieval requests (get operations).
cmd_set Total number of storage requests (set operations).
get_hits Number of keys that have been requested and found present.
limit_maxbytes Number of bytes this server is permitted to use for storage.
bytes Current number of bytes used by this server to store items.
evictions Number of valid items removed from cache to free memory for new items.

9. Have firewall, make sure port 11211 is in the allowed ports. I have CSF firewall, so i editted /etc/csf/csf.conf
And added 11211 to the TCP_IN and TCP_OUT line and restarted firewall by command "csf -r"

10. PHP testing script for memcache:

<?php
$mem = new Memcache();
$mem->addServer("127.0.0.1", 11211);

$result = $mem->get("blah");

if ($result) {
echo $result;
} else {
echo "No matching key found. I'll add that now!";
$mem->set("blah", "I am data! I am held in memcached!") or die("Couldn't save anything to memcached...");
}
?>

Fli
11-19-2014, 09:59 AM
Hi, im newbie too, but i would check "memcached-tool" command (mentioned in the first post) output. if evictions is zero or near zero, i guess you dont need to increase memory size, maybe