歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Ubuntu環境下的php-Redis 配置與php使用入門

Ubuntu環境下的php-Redis 配置與php使用入門

日期:2017/2/28 14:29:42   编辑:Linux教程

Ubuntu環境下的php-Redis 配置與php使用入門

php-redis配置

1、安裝php5-dev

(如果沒有phpize),安裝php5-dev

sudo apt-get install php5-dev

2、安裝phpredis

獲取最新的版本代碼進行編譯

wget --no-check-certificate http://github.com/nicolasff/phpredis/tarball/master -O phpredis.tar.gz
tar phpredis.tar.gz
cd nicolasff-phpredis-94e0649
phpize
./configure
make
make install

3、修改php.ini

添加redis.so模塊

vim /etc/php5/apache2/php.ini

vim /etc/php5/cli/php.ini

都添加下面一行

extension=redis.so

4、重啟apache

etc/init.d/apache2 restart

php使用

<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$redis->set('key', 'hello world');
echo $redis->get('key');
?>

Ubuntu 14.04下Redis安裝及簡單測試 http://www.linuxidc.com/Linux/2014-05/101544.htm

Redis集群明細文檔 http://www.linuxidc.com/Linux/2013-09/90118.htm

Ubuntu 12.10下安裝Redis(圖文詳解)+ Jedis連接Redis http://www.linuxidc.com/Linux/2013-06/85816.htm

Redis系列-安裝部署維護篇 http://www.linuxidc.com/Linux/2012-12/75627.htm

CentOS 6.3安裝Redis http://www.linuxidc.com/Linux/2012-12/75314.htm

Redis安裝部署學習筆記 http://www.linuxidc.com/Linux/2014-07/104306.htm

Redis配置文件redis.conf 詳解 http://www.linuxidc.com/Linux/2013-11/92524.htm

更多Ubuntu相關信息見Ubuntu 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=2

Copyright © Linux教程網 All Rights Reserved