{"id":16269,"date":"2024-05-20T17:21:34","date_gmt":"2024-05-20T17:21:34","guid":{"rendered":"https:\/\/hostvento.com\/kb\/web-hosting\/what-is-redis-and-how-to-install-it\/"},"modified":"2024-06-15T03:16:29","modified_gmt":"2024-06-15T03:16:29","slug":"what-is-redis-and-how-to-install-it","status":"publish","type":"docs","link":"https:\/\/www.hostvento.com\/kb\/docs\/hosting-faqs\/what-is-redis-and-how-to-install-it\/","title":{"rendered":"What Is Redis And How To Install It ?"},"content":{"rendered":"\n<p>What Is Redis ?<\/p>\n\n\n\n<p>Redis is an BSD licensed, open source, advanced key-value cache and store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets, sorted sets, bitmaps and hyperloglogs. Refer&nbsp;<strong>redis.io\/topics\/introduction<\/strong>&nbsp;to know more about Redis.<\/p>\n\n\n\n<p>We will learn how to install redis on a CentOS cPanel server. On a CentOS cPanel server, we will need to install redis daemon &amp; the redis PHP extension. Once installed &amp; enabled it helps in boosting the eCommerce website performance.<\/p>\n\n\n\n<p><strong><em>Install Redis Daemon<\/em><\/strong><\/p>\n\n\n\n<p>cd \/usr\/local\/<br>wget http:\/\/download.redis.io\/releases\/redis-2.8.12.tar.gz<br>tar -xvzf redis-2.8.12.tar.gz<br>cd redis-2.8.12<br>make<br>cp src\/redis-server \/usr\/local\/bin<br>cp src\/redis-cli \/usr\/local\/bin<br>mkdir -p \/etc\/redis<br>mkdir -p \/var\/redis<br>cp redis.conf \/etc\/redis\/redis.conf<\/p>\n\n\n\n<p>Now, let\u2019s edit \/etc\/redis\/redis.conf &amp; configure it to work with the server. Set the values as below.<\/p>\n\n\n\n<p>daemonize yes<br>port 6379<br>bind 127.0.0.1<br>dir \/var\/redis\/<br>logfile \/var\/log\/redis.log<br>pidfile \/var\/run\/redis.pid<\/p>\n\n\n\n<p>We will now need a startup script which will start, stop, restart redis on your server. Create a file \/etc\/init.d\/redis &amp; add below content. Set permissions to 755 so that the file is executable.<\/p>\n\n\n\n<p>#!\/bin\/sh<br>#<br># redis \u2013 this script starts and stops the redis-server daemon<br>#<br># chkconfig: \u2013 85 15<br># description: Redis is a persistent key-value database<br># processname: redis-server<br># config: \/etc\/redis\/redis.conf<br># config: \/etc\/sysconfig\/redis<br># pidfile: \/var\/run\/redis.pid<\/p>\n\n\n\n<p># Source function library.<br>. \/etc\/rc.d\/init.d\/functions<\/p>\n\n\n\n<p># Source networking configuration.<br>. \/etc\/sysconfig\/network<\/p>\n\n\n\n<p># Check that networking is up.<br>[ \u201c$NETWORKING\u201d = \u201cno\u201d ] &amp;&amp; exit 0<\/p>\n\n\n\n<p>redis=\u201d\/usr\/local\/bin\/redis-server\u201d<br>prog=$(basename $redis)<\/p>\n\n\n\n<p>REDIS_CONF_FILE=\u201d\/etc\/redis\/redis.conf\u201d<\/p>\n\n\n\n<p>[ -f \/etc\/sysconfig\/redis ] &amp;&amp; . \/etc\/sysconfig\/redis<\/p>\n\n\n\n<p>lockfile=\/var\/lock\/subsys\/redis<\/p>\n\n\n\n<p>start() {<br>[ -x $redis ] || exit 5<br>[ -f $REDIS_CONF_FILE ] || exit 6<br>echo -n $\u201dStarting $prog: \u201d<br>daemon $redis $REDIS_CONF_FILE<br>retval=$?<br>echo<br>[ $retval -eq 0 ] &amp;&amp; touch $lockfile<br>return $retval<br>}<\/p>\n\n\n\n<p>stop() {<br>echo -n $\u201dStopping $prog: \u201d<br>killproc $prog -QUIT<br>retval=$?<br>echo<br>[ $retval -eq 0 ] &amp;&amp; rm -f $lockfile<br>return $retval<br>}<\/p>\n\n\n\n<p>restart() {<br>stop<br>start<br>}<\/p>\n\n\n\n<p>reload() {<br>echo -n $\u201dReloading $prog: \u201d<br>killproc $redis -HUP<br>RETVAL=$?<br>echo<br>}<\/p>\n\n\n\n<p>force_reload() {<br>restart<br>}<\/p>\n\n\n\n<p>rh_status() {<br>status $prog<br>}<\/p>\n\n\n\n<p>rh_status_q() {<br>rh_status &gt;\/dev\/null 2&gt;&amp;1<br>}<\/p>\n\n\n\n<p>case \u201c$1\u2033 in<br>start)<br>rh_status_q &amp;&amp; exit 0<br>$1<br>;;<br>stop)<br>rh_status_q || exit 0<br>$1<br>;;<br>restart|configtest)<br>$1<br>;;<br>reload)<br>rh_status_q || exit 7<br>$1<br>;;<br>force-reload)<br>force_reload<br>;;<br>status)<br>rh_status<br>;;<br>condrestart|try-restart)<br>rh_status_q || exit 0<br>;;<br>*)<br>echo $\u201dUsage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}\u201d<br>exit 2<br>esac<\/p>\n\n\n\n<p>Update the system services &amp; configure redis daemon to start after server reboot.<\/p>\n\n\n\n<p>chkconfig \u2013add redis<br>chkconfig redis on<\/p>\n\n\n\n<p>Start the redis service with command below. You can use command&nbsp;<strong>redis-cli ping<\/strong>&nbsp;to check if it works properly. If you get a result PONG it means redis is working.<\/p>\n\n\n\n<p>\/etc\/init.d\/redis start<\/p>\n\n\n\n<p>To know more about the command and it\u2019s options use&nbsp;<strong>redis-cli \u2013help<\/strong>.<\/p>\n\n\n\n<p><strong>Inst<em>all Redis PHP Extension<\/em><\/strong><\/p>\n\n\n\n<p>Redis PHP extension is installed by performing couple of commands.<\/p>\n\n\n\n<p>pecl install redis<\/p>\n\n\n\n<p>Open the server\u2019s php.ini file &amp; add&nbsp;<strong>extension=redis.so<\/strong>&nbsp;to it. You can get the server\u2019s php.ini file with command&nbsp;<strong>php -i | grep php.ini<\/strong>. Restart apache (your web server) &amp; you are done<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What Is Redis ? Redis is an BSD licensed, open source, advanced key-value cache and store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets, sorted sets, bitmaps and hyperloglogs. Refer&nbsp;redis.io\/topics\/introduction&nbsp;to know more about Redis. We will learn how to install redis on a CentOS cPanel [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":23377,"menu_order":323,"comment_status":"closed","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-16269","docs","type-docs","status-publish","hentry","no-post-thumbnail"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/docs\/16269","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/comments?post=16269"}],"version-history":[{"count":1,"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/docs\/16269\/revisions"}],"predecessor-version":[{"id":16271,"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/docs\/16269\/revisions\/16271"}],"up":[{"embeddable":true,"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/docs\/23377"}],"wp:attachment":[{"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/media?parent=16269"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/doc_tag?post=16269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}