好文档就是一把金锄头!
欢迎来到金锄头文库![会员中心]
电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

UBUNTU下REDISPHPREDIS安装及配置.docx

7页
  • 卖家[上传人]:宝路
  • 文档编号:23257220
  • 上传时间:2017-11-30
  • 文档格式:DOCX
  • 文档大小:51.59KB
  • / 7 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • UBUNTU 下 REDIS/PHPREDIS 安装及配置一、 安装 REDIS1. 下载安装 TCL如果已经安装了 TCL 可以跳过该步骤#wget /tcl8.5.9-src/unix#./configure#make#make install2. 下载安装 REDIS#redis wget -zxvf redis-2.2.14.tar.gz#make接着进入 redis 目录下的 src 目录src 目录下这些文件作用如下redis-server:Redis 服务器的 daemon 启动程序 redis-cli: Redis 命令行操作工具.你也可以用 telnet 根据其纯文本协议来操作redis-benchmark:Redis 性能测试工具,测试 Redis 在你的系统及你的配置下的读写性能. redis-stat:Redis 状态检测工具,可以检测 Redis 当前状态参数及延迟状况接着建立 Redis 目录,并将上面编译好的程序转移mkdir -p /usr/local/redis/binmkdir -p /usr/local/redis/etcmkdir -p /usr/local/redis/varcp redis-benchmark redis-check-aof redis-cli redis-server redis-check-dump /usr/local/redis/bin/cp ../redis.conf /usr/local/redis/etc/修改 Redis 配置在我们成功安装 Redis 后,我们直接执行 redis-server 即可运行 Redis,此时它是按照默认配置来运行的(默认配置甚至不是后台运行).我们希望 Redis 按我们的要求运行,则我们需要修改配置文件 redis.conf下面是 redis.conf 的主要配置参数的意义:daemonize:是否以后台 daemon 方式运行 pidfile: pid 文件位置 port:监听的端口号 timeout:请求超时时间 loglevel:log 信息级别 logfile:log 文件位置 databases:开启数据库的数量 save * *:保存快照的频率,第一个*表示多长时间,第三个*表示执行多少次写操作.在一定时间内执行一定数量的写操作时,自动保存快照.可设置多个条件.rdbcompression:是否使用压缩 dbfilename:数据快照文件名(只是文件名,不包括目录) dir:数据快照的保存目录(这个是目录) appendonly:是否开启 appendonlylog,开启的话每次写操作会记一条 log,这会提高数据抗风险能力,但影响效率. appendfsync:appendonlylog 如何同步到磁盘(三个选项,分别是每次写都强制调用fsync、每秒启用一次 fsync、不调用 fsync 等待系统自己同步)一般需要把 daemonize no 改为 daemonize yes 其他的看需要修改.3. 连接到 redis$ cd /usr/local/redis~/usr/local/redis$ lbin/ etc/ var/~/redis$ cd bin~/redis/bin$ ./redis-server redis.conf[19308] 02 Feb 08:50:22 # Deprecated configuration directive: "glueoutputbuf"[19308] 02 Feb 08:50:22 # Opening port 6379: bind: Address already in use~/redis/bin$检查是否启动./redis/bin$ netstat -an -t激活 Internet 连接 (服务器和已建立连接的)Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN(这就是 redis 服务) tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN tcp6 0 0 :::22 :::* LISTEN tcp6 0 0 ::1:631 :::* LISTEN~/redis/bin$ ps -ef|grep redis-serverusr 17773 1 0 07:34 ? 00:00:03 ./redis-server redis.confusr 20275 19269 0 08:54 pts/1 00:00:00 grep --color=auto redis-server4. 连接到 redis~/redis/bin$ telnet localhost 6379Trying ::1...Trying 127.0.0.1...Connected to localhost.Escape character is '^]'.二、安装 phpredis 模块 phpredis解压shell> cd phpredisshell> /usr/local/php/bin/phpize 这个 phpize 是安装 php 模块的shell> ./configure –with-php-config=/usr/local/php/bin/php-configshell> makeshell> make install接下来在 php.ini 中添加 extension=redis.so 先要看看有没有 extension_dir=/…….重启 apache 或者 nginx三、测试是否成功:phpinfo();查看是否有: redis 模块的支持四、找不到文件(Cannot find config.m4 ) 在需要扩展编译的 PHP 模块目录中进行/usr/local/php/bin/phpize 这样才不会报错 使用 phpize 建立 php 扩展(Cannot find config.m4) .php 源码:/root/soft/php-5.3.4php 安装: /usr/local/php[root@ns root]# phpizeCannot find config.m4.Make sure that you run '/usr/local/php/bin/phpize' in the top level source directory of the module[root@ns root]# phpizeCannot find config.m4.Make sure that you run '/usr/local/php/bin/phpize' in the top level source directory of the module在/usr/local/src/php-4.3.5/ext 下找到这个工具来建立一个 php 扩展的一个框架[root@ns ext]#cd /root/soft/php-5.3.4/ext/[root@ns ext]# ./ext_skel --extname=my_moduleCreating directory my_moduleCreating basic files: config.m4 .cvsignore my_module.c php_my_module.h CREDITS EXPERIMENTAL tests/001.phpt my_module.php [done].To use your new extension, you will have to execute the following steps:1. $ cd ..2. $ vi ext/my_module/config.m43. $ ./buildconf4. $ ./configure --[with|enable]-my_module5. $ make6. $ ./php -f ext/my_module/my_module.php7. $ vi ext/my_module/my_module.c8. $ make执行了这个步骤以后你会看到这样的结果Repeat steps 3-6 until you are satisfied with ext/my_module/config.m4 andstep 6 confirms that your module is compiled into PHP. Then, start writingcode and repeat the last two steps as often as necessary.这样以后我们会在这个目录下生成一个目录叫 my_module进入这里面我们看看[root@ns ext]# cd my_module/[root@ns my_module]# lsconfig.m4 EXPERIMENTAL my_module.php testsCREDITS my_module.c php_my_module.h然后我们要修改文件顺序是configue.m4my_module.cphp_my_module.h使用文本编辑器打开 config.m4 文件,文件内容大致如下:dnl $Id$ddnl config.m4 for extension my_modulednl don't forget to call PHP_EXTENSION(my_module)dnl Comments in this file start with the string 'dnl'.dnl Remove where necessary. This file will not workdnl without editing.dnl If your extension references something external, use with:dnl PHP_ARG_WITH(my_module, for my_module support,dnl Make sure that the comment is aligned:dnl [ --with-my_module Include my_module support])dnl Otherwise use enable:dnl PHP_ARG_ENABLE(my_module, whether to enable my_module support,dnl Make sure that the c。

      点击阅读更多内容
      关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
      手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
      ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.