{"id":1142,"date":"2015-01-12T23:16:28","date_gmt":"2015-01-12T14:16:28","guid":{"rendered":"http:\/\/lovelinux.mydns.jp\/?p=1142"},"modified":"2015-01-12T23:19:43","modified_gmt":"2015-01-12T14:19:43","slug":"php%e3%81%8b%e3%82%89redis%e3%82%92%e5%88%a9%e7%94%a8%e3%81%99%e3%82%8b%e3%80%9ccentos7","status":"publish","type":"post","link":"https:\/\/lovelinux.mydns.jp\/?p=1142","title":{"rendered":"PHP\u304b\u3089Redis\u3092\u5229\u7528\u3059\u308b\u301cCentOS7"},"content":{"rendered":"<h3>\u306f\u3058\u3081\u306b<\/h3>\n<p>PHP\u304b\u3089Redis\u3092\u5229\u7528\u3059\u308b\u306b\u306f phpredis\u3068\u3044\u3046\u306e\u304c\u30e1\u30b8\u30e3\u30fc\u306a\u65b9\u6cd5\u306e\u3088\u3046\u306a\u306e\u3067\u3001\u4eca\u56de\u306fCentOS7\u306bphpredis\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3001\u30a2\u30af\u30bb\u30b9\u3059\u308b\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<h3>CentOS7 64bit\u306eyum\u30ea\u30dd\u30b8\u30c8\u30ea\u306bEPEL\u3092\u8ffd\u52a0<\/h3>\n<p>[bash]<br \/>\n$ sudo yum install epel-release<br \/>\n[\/bash]<\/p>\n<p>\u53c2\u8003URL<br \/>\n<a href=\"http:\/\/www.kakiro-web.com\/linux\/epel-install.html\">http:\/\/www.kakiro-web.com\/linux\/epel-install.html<\/a><\/p>\n<h3>php-pecl-redis\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>[bash]<br \/>\n$ sudo yum -y install php-pecl-redis &#8211;enablerepo=epel<br \/>\n[\/bash]<\/p>\n<h3>PHP\u3067Redis\u3092\u6709\u52b9\u306b<\/h3>\n<p>[bash]<br \/>\n$ sudo nano \/etc\/php.ini<br \/>\n[\/bash]<\/p>\n<p>\u672b\u5c3e\u306b\u8ffd\u52a0<br \/>\n[bash]<br \/>\n[redis]<br \/>\nextension=redis.so<br \/>\n[\/bash]<\/p>\n<h3>php-fpm\u518d\u8d77\u52d5<\/h3>\n<p>[bash]<br \/>\n$ sudo systemctl restart php-fpm<br \/>\n[\/bash]<\/p>\n<h3>\u53c2\u8003URL redis\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u65e5\u672c\u8a9e\u8a33 <\/h3>\n<p><a href=\"http:\/\/redis.shibu.jp\/\">http:\/\/redis.shibu.jp\/<\/a><\/p>\n<h3>\u63a5\u7d9a\u30b5\u30f3\u30d7\u30eb<\/h3>\n<p>[php]<br \/>\n<?php\necho \"<!DOCTYPE html>&#8220;;<br \/>\necho &#8220;<html>&#8220;;<br \/>\necho &#8220;<head>&#8220;;<br \/>\necho &#8220;<meta charset='utf-8'>&#8220;;<br \/>\necho &#8220;<title>PHP Redis\u63a5\u7d9a\u30b5\u30f3\u30d7\u30eb<\/title>&#8220;;<br \/>\necho &#8220;<\/head>&#8220;;<br \/>\necho &#8220;<body>&#8220;;<\/p>\n<p>echo &#8220;hello -redis<br \/>&#8220;;<br \/>\n$redis = new Redis();<br \/>\n$redis->connect(&#8220;127.0.0.1&#8221;,6379);<\/p>\n<p>$redis->select(2);<br \/>\n$redis->set(&#8220;abc&#8221;,&#8221;123&#8243;);<br \/>\n$value = $redis->get(&#8220;abc&#8221;);<\/p>\n<p>echo $value . &#8220;<br \/>&#8220;;<\/p>\n<p>$keys = $redis->keys(&#8220;*&#8221;);<br \/>\nvar_dump($keys);<br \/>\necho &#8220;<br \/>&#8220;;<\/p>\n<p>$redis->rpush(&#8220;test_logs&#8221;,&#8221;abc&#8221;);<br \/>\n$redis->rpush(&#8220;test_logs&#8221;,&#8221;efg&#8221;);<br \/>\n$redis->rpush(&#8220;test_logs&#8221;,&#8221;xyz&#8221;);<\/p>\n<p>$len = $redis->llen(&#8220;test_logs&#8221;);<br \/>\necho $len . &#8220;<br \/>&#8220;;<\/p>\n<p>for ($i = 0 ; $i < $len ; $i++){\n   $log = $redis->lindex(&#8220;test_logs&#8221;, $i);<br \/>\n   echo $log . &#8220;<br \/>&#8220;;<br \/>\n}<\/p>\n<p>$redis->close();<\/p>\n<p>echo &#8220;<\/body>&#8220;;<br \/>\necho &#8220;<\/html>&#8220;;<\/p>\n<p>[\/php]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u306b PHP\u304b\u3089Redis\u3092\u5229\u7528\u3059\u308b\u306b\u306f phpredis\u3068\u3044\u3046\u306e\u304c\u30e1\u30b8\u30e3\u30fc\u306a\u65b9\u6cd5\u306e\u3088\u3046\u306a\u306e\u3067\u3001\u4eca\u56de\u306fCentOS7\u306bphpredis\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3001\u30a2\u30af\u30bb\u30b9\u3059\u308b\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059\u3002 CentOS7 64bit\u306eyum\u30ea\u30dd\u30b8\u30c8\u30ea\u306bEPEL\u3092\u8ffd\u52a0 [bash] $ sudo yum install epel-release [\/bash] \u53c2\u8003URL http:\/\/www.kakiro-web.com\/linux\/epel-install.html php-pecl-redis\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb [bash] $ sudo yum -y install php-pecl-redis &#8211;enablerepo=epel [\/bash] PHP\u3067Redis\u3092\u6709\u52b9\u306b [bash] $ sudo nano \/etc\/php.ini [\/bash] \u672b\u5c3e\u306b\u8ffd\u52a0 [bash] [redis] extension=redis.so [\/bash] php-fpm\u518d\u8d77\u52d5 [bash] $ sudo systemctl restart php-fpm [\/bash] \u53c2\u8003URL redis\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u65e5\u672c\u8a9e\u8a33 http:\/\/redis.shibu.jp\/ \u63a5\u7d9a\u30b5\u30f3\u30d7\u30eb [php]<\/p>\n","protected":false},"author":1,"featured_media":1145,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[3,2,1],"tags":[51,15,17],"class_list":{"0":"post-1142","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-3","8":"category-2","9":"category-1","10":"tag-centos7","11":"tag-php","12":"tag-redis"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/1142","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1142"}],"version-history":[{"count":4,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/1142\/revisions"}],"predecessor-version":[{"id":1147,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/1142\/revisions\/1147"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/media\/1145"}],"wp:attachment":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}