banner



How To Install Memcached On Centos

Memcached is an open-source distributed memory object caching program that allows the states to improve and speed up the performance of dynamic spider web applications by caching data and objects in Memory.

Memcached is also used to cache entire database tables and queries to amend the performance of the database. It is the simply caching system bachelor freely and used by many large sites like YouTube, Facebook, Twitter, Reddit, Drupal, Zynga, etc.

Read Also: How to Install and Configure Memcached on CentOS 8

Memcached can commit to deprival of service attacks if not correctly configured. In this article, nosotros will explain how to install and secure your Memcached server on CentOS seven Linux distribution. These given instructions also piece of work on RHEL and Fedora Linux.

Installing Memcached in CentOS 7

First, update your local software parcel index and and then install Memcached from the official CentOS repositories using post-obit yum commands.

# yum update # yum install memcached        
Install Memcached in CentOS 7
Install Memcached in CentOS 7

Next, nosotros will install libmemcached – a customer library that offers a couple of tools to manage your Memcached server.

# yum install libmemcached        
Install Memcached Library in CentOS 7
Install Memcached Library in CentOS 7

Memcached should now exist installed on your CentOS system as a service, along with the tools that required y'all to test its connectivity. Now we can proceed further to secure its configuration settings.

Securing Memcached Configuration Settings

To make clinch that installed Memcached service is listening on the 127.0.0.1 local interface, we will alter the OPTIONS variable in the /etc/sysconfig/memcached configuration file.

# vi /etc/sysconfig/memcached        

Search for the OPTIONS variable, and add the -50 127.0.0.one -U 0 to OPTIONS variable. These configuration settings will protect our server from denial of service attacks.

/etc/sysconfig/memcached

PORT="11211" USER="memcached" MAXCONN="1024" CACHESIZE="64"          OPTIONS="-fifty 127.0.0.1 -U 0"                  
Secure Memcached Configuration
Secure Memcached Configuration

Permit'south discuss each of the above parameters in item.

  1. PORT : The port used by Memcached to run.
  2. USER : The offset-up daemon for Memcached service.
  3. MAXCONN : The value used to gear up max simultaneous connections to 1024. For decorated web servers, you tin can increase to whatsoever number based on your requirements.
  4. CACHESIZE : Set cache size memory to 2048. For decorated servers, you tin increase upwards to 4GB.
  5. OPTIONS : Set the IP address of the server, and so that Apache or Nginx web servers can connect to information technology.

Restart and enable your Memcached service to apply your configuration changes.

# systemctl restart memcached # systemctl enable memcached        

Once started, you lot can confirm that your Memcached service is bound to the local interface and listening only on TCP connections using following netstat command.

# netstat -plunt        
Verify Memcached Server
Verify Memcached Server

Y'all can also check the stats of the server using memcached-tool as shown.

# memcached-tool 127.0.0.1 stats        
Check Memcached Running Status
Check Memcached Running Condition

Now brand sure to allow admission to the Memcached server by opening a port 11211 on your firewall as shown.

# firewall-cmd --permanent --zone=public --add-port=11211/tcp        

Install Memcached PHP extension

Now, install a PHP extension to work with the Memcached daemon.

# yum install php-pecl-memcache

Install Memcached Perl Library

Install Perl library for Memcached.

# yum install perl-Enshroud-Memcached

Install Memcached Python Library

Install python library for Memcached.

# yum install python-memcached

Restart Web Server

Restart the Apache or Nginx service to reflect changes.

# systemctl restart httpd # systemctl restart nginx        

Cache MySQL Queries with Memcached

It isn't an easy task for all, you need to use API'southward to modify your PHP codes to enable MySQL caching. Yous tin can find the examples codes at Memcache with MySQL and PHP.

That's Information technology! In this article, we take expanded how to install and secure your Memcached server to the local network interface. If you have faced any issues during installation, do inquire for assist in our comment section beneath.

If You lot Appreciate What Nosotros Do Here On TecMint, You lot Should Consider:

TecMint is the fastest growing and most trusted customs site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you lot are reading, please consider buying us a coffee ( or 2 ) equally a token of appreciation.

Support Us

We are thankful for your never ending support.

Source: https://www.tecmint.com/install-memcached-on-centos-7/

Posted by: pannellcapent.blogspot.com

0 Response to "How To Install Memcached On Centos"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel