Install Memcached Memory Caching
we will Install Memcached Memory Caching in Linux sever to improve website speed.
Memcached is a distributed memory object caching system which is used to speed up the dynamic database-driven website by caching data and object in RAM to reduce the number of times external data source must be read.
Memcached is also used to cache entire database tables and queries to improve the performance of database.
Check Out : RPM useful Commands List
Requirements : Apache with php installed and CentOS machine.
Step 1 : Install Memcached
yum install memcached -y
Step 2 : Start the Service and enable at boot time
systemctl start memcached && systemctl enable memcached
Check Out : Configure Varnish To Work With Apache
You can also install libmemcached. This will provide you several tools which will work with Memcached.
Step 3 : You can also check version and default port used for Memcached
Step 4 : You should disable the UDP it can protect you from Denial of service attacks(DOS).
Configuration file location : /etc/sysconfig/memcached
Check Out : ByPass Root Password Of Mysql Server
Securing Server :-
Now we will bind the localhost Ip address to Memcached which will help us to protect from Denial of service attacks and “ -l 127.0.0.1 “.
If you want to disable UDP in Memcached So you need to use “ -U 0 “ this with option in /etc/sysconfig/memcached file.
If you want you can also change port here other settings too.
Restart the service and make sure Memcached should listen on 127.0.0.1. You can also use your Web server Ip address here i have used the localhost.
Check Out : Install AIDE ( File Integrity)
systemctl restart memcached && netstat -tnlp | grep memcache
Step 4 : If you want to you can check Memcached server status,
memcached-tool 192.168.185.143 stats
Step 5 : Don’t forgot to add Memcached port in the firewall
firewall-cmd –permanent –add-port=11211/tcp
Check Out : Force User to Change Password At first Login
Step 6 : PHP module for Memcached
yum install php-perl-memcache
Check Remote Connectivity,
echo stats | nc memcache_host_name_or_IP 11211