Memcached is a software that implements a RAM caching service based on a hash table.
You can also install this application at one-click checkout
Detailed description of this One-Click-Apps
Memcached is a server that stores some data in RAM with a specified lifetime. The data is accessed by a key (name). You can think of Memcached as a hash table stored on the server. It's mostly used to cache web page code, database query results, etc.
Before installing it, let's update the system:
# apt-get update && apt-get upgrade
Now use the following command to install memcached and the memcache module for PHP:
# apt-get install memcached php5-memcache
Next, we check to see if the daemon is running
# netstat -tap | grep memcached tcp 0 0 0 localhost:11211 *:* LISTEN 21488/memcached
By default, memcached port 11211 with IP:127.0.0.1 (localhost)
It is also possible to edit these settings, e.g. you want to open access from an external IP, you need to edit the memcached settings file - /etc/memcached.conf.
parameter is responsible for the IP address that the memcached daemon is listening to.
parameter specifies how much memory to allocate for caching in megabytes.
standard port that the memcached daemon listens on.
Next, we need to reboot the web server to connect the memcache module
Or restart the configuration file itself:
Configure the firewall for Memcached
Add the following rules to allow connections (for memcached to work):
iptables -A INPUT -p tcp --destination-port 11211 -m state --state NEW -m iprange --src-range 188.8.131.52-184.108.40.206 -j ACCEPT iptables -A INPUT -p udp --destination-port 11211 -m state --state NEW -m iprange --src-range 220.127.116.11-18.104.22.168 -j ACCEPT
open all outgoing ports
iptables -P OUTPUT ACCEPT
Open port 80 for all incoming connections
iptables -A INPUT -dport 80 -j ACCEPT
Open ports 22 and 5432 only for a specific IP
iptables -A INPUT -m multiport -dports 22,5432 -s IP_ADDRESS -j ACCEPT