-
安裝 EPEL 套件:
#yum -y install epel-release
-
安裝 redis 相關套件:
#yum install -y redis
-
開啟防火牆設定:
#firewall-cmd --permanent --add-port=6379/tcp #firewall-cmd --reload
-
啟動 Redis Server 服務:
#systemctl enable redis.service #systemctl start redis.service
-
查詢開啟的 port 號:
#netstat -antlp | grep redis
-
測試 Redis Server 服務:
#rdis-cli ping
※重要設定檔: - /etc/redis.conf
- /etc/redis-sentinel.conf
基本設定:
-
修改登入密碼:
#vim /etc/redis.conf (移除前方的註解符號) requirepass redhat
-
重新啟動 Redis Server 服務:
#systemctl restart redis.service
-
再次測試 Redis Server 服務:
#redis-cli -a 'redhat' -h 192.168.5.61 ping
利用 PHP 連結 Redis Server:
-
安裝相關所需要的套件:
#yum -y install http php php-mbstring php-mcrypt php-gd php-redis
-
重新啟動 Httpd Server 服務:
#systemctl restart httpd.service
※注意::要開啟 Http Server 的防火牆設定:
#firewall-cmd --permanent --add-service=http #firewall-cmd --reload
※注意::要開啟 SELinux 相關設定:
#setsebool -P httpd_can_network_connect on
-
寫一支 PHP 的程式,測試是否可以運作 Redis :
#vim /var/www/html/test.php (內容如下:) <?php $redis = new Redis(); $redis->connect('127.0.0.1', 6379); $redis->set("foo", "bar"); echo $redis->get("foo"); ?>
安裝 Redis Server 管理後台--phpRedisAdmin:
-
下載 phpRedisAdmin 套件:
#git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git #cd phpRedisAdmin #git clone https://github.com/nrk/predis.git vendor
-
修改 phpRedisAdmin 連線設定:
#cd includes/ #cp config.sample.inc.php config.inc.php #vim config.inc.php (修改下列設定,並移去註解符號) 'auth' => 'redhat'
- 開啟 Firefox ,輸入網址 http://127.0.0.1/phpRedisAdmin ,即可看見!
將 php 的 session ,交給 Redis Server
-
修改 php.ini 檔案:
#vim /etc/php.ini session.save_handler = redis session.save_path = "tcp://192.168.1.61:6379?weight=1"
※注意:http://blog.51yip.com/php/1616.html -
重新啟動 httpd :
#systemctl restart httpd
- https://magiclen.org/ubuntu-redis-php/
- https://bepsvpt.wordpress.com/2016/04/08/install-redis-and-deal-with-warning-message/
- https://laravel.tw/docs/5.1/redis
- http://www.runoob.com/redis/redis-tutorial.html
- http://ithelp.ithome.com.tw/articles/10105731
- http://kejyun.github.io/Laravel-4-Documentation-Traditional-Chinese/docs/redis/
- http://xyz.cinc.biz/2015/09/centos7-redis-php.html
- https://dotblogs.com.tw/supershowwei/2016/02/02/112238
- http://sharadchhetri.com/2014/10/04/install-redis-server-centos-7-rhel-7/
- https://github.com/erikdubbelboer/phpRedisAdmin
- https://bepsvpt.wordpress.com/2016/04/08/install-redis-and-deal-with-warning-message/