Memcached like it’s name says, is a Cache system for your website. But let me explain a bit further why you should install it on your server.
If your server has a lot of visitors and it is based on a PHP-System, it would be worth it to install a cache system. Memcached or any Cache reduces the strain on your MySQL databases by caching or saving requests that are normally performed often to your database.
An example would be a WordPress site. It is purely based on PHP and all the posts and pages are not in HTML rather they are in PHP where all requests go to the database. So to reduce latency, loading times, TFFB, etc… You should install cache. There are many systems like nginx, memecached, etc…
sudo dnf install memcached libmemcached sudo systemctl enable memcached --now sudo systemctl status memcached
memcached.service - memcached daemon Loaded: loaded (/usr/lib/systemd/system/memcached.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2020-04-13 20:12:52 UTC; 2s ago ...
That easy. You have installed Memcached.
If the client and the cache are running on the same machine, ignore this part. Otherwise follow the tutorial.
Setting up remote access
Let’s suppose your cache server ip is 10.0.0.1 and you want to connect to the client 10.0.0.2.
Allow the connection to the firewall on the port 11211
sudo firewall-cmd --new-zone=memcached --permanent sudo firewall-cmd --zone=memcached --add-port=11211/udp --permanent sudo firewall-cmd --zone=memcached --add-port=11211/tcp --permanent sudo firewall-cmd --zone=memcached --add-source=10.0.0.2/32 --permanent sudo firewall-cmd --reload
sudo nano /etc/sysconfig/memcached
You will see a options parameter, there add the following line
Save the file and restart the Memcached service.
sudo systemctl restart memcached
Connecting to Memcached
If you wish to connect to WordPress, Dupral or Magneto you will need to have php-peel-memcached installed. This is also useful for any PHP CMS. To install it do as following:
sudo dnf install php-pecl-memcache
If you have any more doubts please refer to memcached wiki on GitHub here