{"id":2876,"date":"2018-11-04T21:36:39","date_gmt":"2018-11-04T16:06:39","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=2876"},"modified":"2018-11-04T21:36:39","modified_gmt":"2018-11-04T16:06:39","slug":"how-to-install-redis-cache-server-in-centos-7","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/how-to-install-redis-cache-server-in-centos-7\/","title":{"rendered":"How to Install Redis cache server in centos 7."},"content":{"rendered":"<h2>How to Install Redis cache server in centos 7.<\/h2>\n<p><strong>Date Posted: 02 -09-2018<\/strong><\/p>\n<p>Redis is an in-memory data structure store, used as a database server, cache, and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps and streams.<\/p>\n<p>It also provides PHP module for communication between PHP script with Redis server. Redis is Written in C programming language.<\/p>\n<p>In this tutorial will help you with the installation of Redis server along with PHP Redis PHP extensions on a CentOS 7 server.Let us have a step by step instructions, how to implement it.<\/p>\n<h3 class=\"heading1\">Step 1 : Prerequisites<\/h3>\n<p>1. Login to your server using secured shell access with the root account.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\"># ssh root@remote<\/pre>\n<p>2. Redis packages are not available in our default <strong>Yum<\/strong> Repository, so that Install a <strong>EPEL\u00a0<\/strong> Reposistory on your server . To Enable this Repository, execute the following command shown below,<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@sms ~]# sudo yum install epel-release\r\n<\/pre>\n<p>Package epel-release-7-11.noarch already installed and latest version. This will be a end output message conveyed to you.<\/p>\n<h3>Step\u00a0 2 : Install Redis Server<\/h3>\n<p>1. Now, we can utilize a Yum repository , to install a Redis on our server.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@sms ~]# sudo yum install redis<\/pre>\n<p>2. After a\u00a0 successful installation.<strong>start<\/strong> Redis service and <strong>enable<\/strong> to auto-start on system reboot.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@sms ~]# sudo systemctl start redis<\/pre>\n<p>Enable it and check,whether the Redis service is active in our server.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@sms ~]# sudo systemctl enable redis\r\n\r\n Created symlink from \/etc\/systemd\/system\/multi-user.target.wants\/redis.service to \/usr\/lib\/systemd\/system\/redis.service.<\/pre>\n<h3>Step 3 : Install Redis PHP extension<\/h3>\n<p>1.\u00a0 Check\u00a0 PHP\u00a0 is\u00a0 installed on your system.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@sms conf]# php --version\r\n\r\nPHP 7.1.23 (cli) (built: Oct 10 2018 12:11:12) ( NTS )\r\nCopyright (c) 1997-2018 The PHP Group\r\nZend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies.<\/pre>\n<p>In my system, PHP version\u00a0 7.1\u00a0 is enabled.<\/p>\n<p>2.\u00a0\u00a0To enable Redis PHP extension on your CentOS server. Follow these commands below,<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\"># pecl install igbinary igbinary-devel redis<\/pre>\n<p>In many of the system shows an error,\u00a0<strong>-bash: pecl: command not found.\u00a0<\/strong>To solve this , download the important PHP &#8211; Modules to enable the pecl command.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@sms ~]# yum install php-devel<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@sms ~]# yum install php-pear<\/pre>\n<p>After installation of this PHP module, Pecl command is Enabled\u00a0 . Now , Use the pecl to do a Redis PHP extension.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\"># pecl install igbinary igbinary-devel redis<\/pre>\n<p>3. After\u00a0 executed\u00a0 a\u00a0 above command ,verify Redis PHP extension is enabled or not.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@sms ~]# php -m | grep redis<\/pre>\n<p>Redis server has been installed on your system along with the PHP extension.<\/p>\n<h3 class=\"heading1\">Step 4 : Configure Redis as a Cache Server<\/h3>\n<p>Redis to make any\u00a0 important changes you can use its configuration file\u00a0 is: <strong>\/etc\/redis\/redis.conf. <\/strong>Edit the Redis configuration file in a text editor to make changes,<\/p>\n<p>1 . Configuring a Redis cache server.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@sms \/]# cd \/etc\r\n\r\n[root@sms etc]# mkdir redis\r\n\r\n[root@sms etc]# cd redis\r\n\r\n[root@sms redis]# touch redis.conf\r\n\r\n[root@sms redis]# nano redis.conf<\/pre>\n<p>2.\u00a0Update the following values in Redis configuration file according to your requirement. You can increase max memory limit as per available on your server.<\/p>\n<p><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/redis-config.png\"><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-2877\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/redis-config.png\" alt=\"\" width=\"493\" height=\"169\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/redis-config.png 493w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/redis-config-300x103.png 300w\" sizes=\"(max-width: 493px) 100vw, 493px\" \/><\/a><\/p>\n<p>The above configuration tells Redis to remove any key using the LRU algorithm when the max memory of 256mb is reached. Save the configuration file.<\/p>\n<p>3. Restart the Redis service.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@sms redis]# systemctl restart redis<\/pre>\n<h3 class=\"heading1\">Step 5 : Test Connection to Redis Server<\/h3>\n<p>Use redis-cli tool to verify the connection between Redis server and redis-cli. Check the Ping &#8211; pong Response in it.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@sms redis]# redis-cli\r\n\r\n127.0.0.1:6379&gt; ping\r\n\r\nPONG\r\n\r\n127.0.0.1:6379&gt;<\/pre>\n<p>Thats it ! Redis ready for use.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Install Redis cache server in centos 7. Date Posted: 02 -09-2018 Redis is an in-memory data structure store, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1020],"tags":[415,475],"class_list":["post-2876","post","type-post","status-publish","format-standard","hentry","category-containers-kubernetes","tag-centos-7","tag-redis","psol-cat-containers-kubernetes"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-Ko","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2876","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=2876"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2876\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=2876"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=2876"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=2876"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}