无标题文档
wdCP系统 (介绍,功能特性,运行环境,安装说明,演示,常见问题,使用教程) wdCDN系统 (介绍,功能特性,运行环境,安装说明,演示,常见问题,使用手册)
wdOS系统 (介绍,功能特性,运行环境,安装说明,演示,常见问题,使用教程) wdDNS系统 (介绍,功能特性,运行环境,安装说明,演示,常见问题,使用手册)
注册 发贴 提问 回复-必看必看 wddns免费智能 DNS 开通 本地或虚拟机使 用wdcp 一键包在mysql编 译时"卡住"
【300G高防】双线 无视攻击 wdcp官方技术支持/服务 阿里云8折优惠券 无敌云 腾讯云优惠中,现注册更有260代金额券赠送
返回列表 发帖
提问三步曲: 提问先看教程/FAQ索引(wdcp,wdcp_v3,一键包)及搜索,会让你更快解决问题
1 提供详细,如系统版本,wdcp版本,软件版本等及错误的详细信息,贴上论坛或截图发论坛
2 做过哪些操作或改动设置等

温馨提示:信息不详,很可能会没人理你!论坛有教程说明的,也可能没人理!因为,你懂的

[教程] wdcp v3安装redis及添加phpredis扩展

本帖最后由 winran 于 2017-1-12 09:58 编辑

安装时,请注意替换成自己服务器的路径地址!




一、安装redis

a、下载redis:

  

wget   http://download.redis.io/redis-stable.tar.gz

  

tar  -zxvf redis-stable.tar.gz

  

cd  redis-stable

  

make

  

make  install

  
  

b、在redis安装目录下进入utils目录,执行自动安装脚本

  

cd  utils/

  

./install_server.sh

  

一路回车都按照默认设置执行

  

//执行完脚本后,会出现以下提示:

  

Selected  config:

  

Port            : 6379

  

Config  file    : /etc/redis/6379.conf

  

Log  file       : /var/log/redis_6379.log

  

Data  dir       : /var/lib/redis/6379

  

Executable      : /usr/local/bin/redis-server

  

Cli  Executable : /usr/local/bin/redis-cli

  
  

c、添加redis开机自启动

  

//修改文件权限

  

chmod  755 /etc/init.d/redis_6379

  

//添加自启动

  

chkconfig  --add redis_6379

  

chkconfig  --level 345 redis_6379 on

  
  

d、检查远程服务器的6379端口是否被防火墙拦截。假如未开启,则开添加

  

/sbin/iptables  -I INPUT -p tcp --dport 6379 -j ACCEPT

  

/etc/init.d/iptables  restart(视服务器情况而定,如果不知道的话可以选择重启服务器)

  

也可以在wdcp的后台系统管理--iptables添加规则

  

使用安骑士等防火墙软件的自行添加6379端口访问通过的规则

  
  

e、编辑redis配置文件,允许所有ip连接

  

vim  /etc/redis/6379.conf

  

//找到bind 127.0.0.1这一行,替换成下面这行内容

  

bind  0.0.0.0

  

保存退出

  

重启使配置生效:/etc/init.d/redis_6379  restart

  
  

f、通过客户端命令行连接redis


  

//在本地连接

  

redis-cli  -h 127.0.0.1 -p 6379

  
  

二、添加phpredis扩展

  

获取并解压安装包

  

cd

  

wget   https://github.com/phpredis/phpredis/archive/develop.zip

  

unzip  develop.zip

  

注意:若提示未找到“unzip”命令

  

解决办法:运行    yum install unzip -y

  

//进入目录

  

cd  phpredis-develop

  

使用phpize命令添加扩展,phpize命令所在路径根据实际情况修改

  

/www/wdlinux/nginx_php/bin/phpize

  

注意:可能会有“Cannot find  autoconf. Please check your autoconf installation and the $PHP_AUTOCONF  environment variable. Then, rerun this script.”错误

  

解决办法:运行 yum install  -y autoconf

  

再重新运行前面的phpize命令

  

出现类似下图的提示,则代表成功

  

  


  

  

//配置。php-config命令所在路径根据实际情况修改

  

./configure  --with-php-config= /www/wdlinux/apache_php-5.4.38/bin/php-config

  

出现类似下面的内容,说明此步骤没问题

  
  

安装

  

make

  

出现类似下图,说明此步骤成功:

  

  

make install

  

出现类似下面的内容,说明成功:

  

  

代表生成redis.so成功,可以进到该目录去查看是否有生成。该路径也是视实际情况而定。

  

//php.ini中加入redis.so扩展

  

vim   /www/wdlinux/nginx_php/etc/php.ini

  

//加入这一行,保存退出。路径要使用上面装完redis生成redis.so的路径

  

extension=/www/wdlinux/nginx_php /lib/php/extensions/no-debug-non-zts-20121212/redis.so

  

重启web服务(重点是重启php)

  

通过phpinfo查看是否添加了redis扩展

  


(额外帮助信息)启动/关闭服务命令

  

//查看是否启动redis服务

  

ps  -ef | grep redis

  

//启动

  

//etc/init.d/redis_6379   start

  

//通过配置文件启动

  

//usr/local/bin/redis-server   /etc/redis/6379.conf

  

//关闭

  

//etc/init.d/redis_6379   stop

  

//关闭,假如是默认端口号6379,可以省略 -p 6379参数

  

//usr/local/bin/redis-cli  -p 6379 shutdown

  
  
  
分子图

关于该步出错的原因.请大家对应修改.就好了
未命名-1.fw.png
2018-1-12 18:46

TOP

回复 1# winran


  
  1. [root@iZ25x4ajoqbZ phpredis-develop]# /www/wdlinux/php/bin/phpize
  2. Configuring for:
  3. PHP Api Version:         20090626
  4. Zend Module Api No:      20090626
  5. Zend Extension Api No:   220090626
  6. [root@iZ25x4ajoqbZ phpredis-develop]# ./configure    --with-php-config=/www/wdlinux/apache_php-5.5.38/bin/php-config
  7. checking for grep that handles long lines and -e... /bin/grep
  8. checking for egrep... /bin/grep -E
  9. checking for a sed that does not truncate output... /bin/sed
  10. checking for cc... cc
  11. checking for C compiler default output file name... a.out
  12. checking whether the C compiler works... yes
  13. checking whether we are cross compiling... no
  14. checking for suffix of executables...
  15. checking for suffix of object files... o
  16. checking whether we are using the GNU C compiler... yes
  17. checking whether cc accepts -g... yes
  18. checking for cc option to accept ISO C89... none needed
  19. checking how to run the C preprocessor... cc -E
  20. checking for icc... no
  21. checking for suncc... no
  22. checking whether cc understands -c and -o together... yes
  23. checking for system library directory... lib
  24. checking if compiler supports -R... no
  25. checking if compiler supports -Wl,-rpath,... yes
  26. checking build system type... x86_64-unknown-linux-gnu
  27. checking host system type... x86_64-unknown-linux-gnu
  28. checking target system type... x86_64-unknown-linux-gnu
  29. configure: error: Cannot find php-config. Please use --with-php-config=PATH
  30. [root@iZ25x4ajoqbZ phpredis-develop]# ./configure --with-php-config=/www/wdlinux/nginx_php-5.2.17/bin/php-config
  31. checking for grep that handles long lines and -e... /bin/grep
  32. checking for egrep... /bin/grep -E
  33. checking for a sed that does not truncate output... /bin/sed
  34. checking for cc... cc
  35. checking for C compiler default output file name... a.out
  36. checking whether the C compiler works... yes
  37. checking whether we are cross compiling... no
  38. checking for suffix of executables...
  39. checking for suffix of object files... o
  40. checking whether we are using the GNU C compiler... yes
  41. checking whether cc accepts -g... yes
  42. checking for cc option to accept ISO C89... none needed
  43. checking how to run the C preprocessor... cc -E
  44. checking for icc... no
  45. checking for suncc... no
  46. checking whether cc understands -c and -o together... yes
  47. checking for system library directory... lib
  48. checking if compiler supports -R... no
  49. checking if compiler supports -Wl,-rpath,... yes
  50. checking build system type... x86_64-unknown-linux-gnu
  51. checking host system type... x86_64-unknown-linux-gnu
  52. checking target system type... x86_64-unknown-linux-gnu
  53. checking for PHP prefix... /www/wdlinux/nginx_php-5.2.17
  54. checking for PHP includes... -I/www/wdlinux/nginx_php-5.2.17/include/php -I/www/wdlinux/nginx_php-5.2.17/include/php/main -I/www/wdlinux/nginx_php-5.2.17/include/php/TSRM -I/www/wdlinux/nginx_php-5.2.17/include/php/Zend -I/www/wdlinux/nginx_php-5.2.17/include/php/ext -I/www/wdlinux/nginx_php-5.2.17/include/php/ext/date/lib
  55. checking for PHP extension directory... /www/wdlinux/nginx_php-5.2.17/lib/php/extensions/no-debug-non-zts-20060613
  56. checking for PHP installed headers prefix... /www/wdlinux/nginx_php-5.2.17/include/php
  57. checking if debug is enabled... no
  58. checking if zts is enabled... no
  59. checking for re2c... no
  60. configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
  61. checking for gawk... gawk
  62. checking whether to enable redis support... yes, shared
  63. checking whether to enable sessions... yes
  64. checking whether to enable igbinary serializer support... no
  65. checking for redis igbinary support... disabled
  66. checking for ld used by cc... /usr/bin/ld
  67. checking if the linker (/usr/bin/ld) is GNU ld... yes
  68. checking for /usr/bin/ld option to reload object files... -r
  69. checking for BSD-compatible nm... /usr/bin/nm -B
  70. checking whether ln -s works... yes
  71. checking how to recognize dependent libraries... pass_all
  72. checking for ANSI C header files... yes
  73. checking for sys/types.h... yes
  74. checking for sys/stat.h... yes
  75. checking for stdlib.h... yes
  76. checking for string.h... yes
  77. checking for memory.h... yes
  78. checking for strings.h... yes
  79. checking for inttypes.h... yes
  80. checking for stdint.h... yes
  81. checking for unistd.h... yes
  82. checking dlfcn.h usability... yes
  83. checking dlfcn.h presence... yes
  84. checking for dlfcn.h... yes
  85. checking the maximum length of command line arguments... 1966080
  86. checking command to parse /usr/bin/nm -B output from cc object... ok
  87. checking for objdir... .libs
  88. checking for ar... ar
  89. checking for ranlib... ranlib
  90. checking for strip... strip
  91. checking if cc supports -fno-rtti -fno-exceptions... no
  92. checking for cc option to produce PIC... -fPIC
  93. checking if cc PIC flag -fPIC works... yes
  94. checking if cc static flag -static works... no
  95. checking if cc supports -c -o file.o... yes
  96. checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
  97. checking whether -lc should be explicitly linked in... no
  98. checking dynamic linker characteristics... GNU/Linux ld.so
  99. checking how to hardcode library paths into programs... immediate
  100. checking whether stripping libraries is possible... yes
  101. checking if libtool supports shared libraries... yes
  102. checking whether to build shared libraries... yes
  103. checking whether to build static libraries... no

  104. creating libtool
  105. appending configuration tag "CXX" to libtool
  106. configure: creating ./config.status
  107. config.status: creating config.h
  108. [root@iZ25x4ajoqbZ phpredis-develop]# make
  109. /bin/sh /root/phpredis-develop/libtool --mode=compile cc  -I. -I/root/phpredis-develop -DPHP_ATOM_INC -I/root/phpredis-develop/include -I/root/phpredis-develop/main -I/root/phpredis-develop -I/www/wdlinux/nginx_php-5.2.17/include/php -I/www/wdlinux/nginx_php-5.2.17/include/php/main -I/www/wdlinux/nginx_php-5.2.17/include/php/TSRM -I/www/wdlinux/nginx_php-5.2.17/include/php/Zend -I/www/wdlinux/nginx_php-5.2.17/include/php/ext -I/www/wdlinux/nginx_php-5.2.17/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /root/phpredis-develop/redis.c -o redis.lo
  110. mkdir .libs
  111. cc -I. -I/root/phpredis-develop -DPHP_ATOM_INC -I/root/phpredis-develop/include -I/root/phpredis-develop/main -I/root/phpredis-develop -I/www/wdlinux/nginx_php-5.2.17/include/php -I/www/wdlinux/nginx_php-5.2.17/include/php/main -I/www/wdlinux/nginx_php-5.2.17/include/php/TSRM -I/www/wdlinux/nginx_php-5.2.17/include/php/Zend -I/www/wdlinux/nginx_php-5.2.17/include/php/ext -I/www/wdlinux/nginx_php-5.2.17/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/phpredis-develop/redis.c  -fPIC -DPIC -o .libs/redis.o
  112. env: cc: Permission denied
  113. make: *** [redis.lo] Error 1
  114. [root@iZ25x4ajoqbZ phpredis-develop]# make install
  115. /bin/sh /root/phpredis-develop/libtool --mode=compile cc  -I. -I/root/phpredis-develop -DPHP_ATOM_INC -I/root/phpredis-develop/include -I/root/phpredis-develop/main -I/root/phpredis-develop -I/www/wdlinux/nginx_php-5.2.17/include/php -I/www/wdlinux/nginx_php-5.2.17/include/php/main -I/www/wdlinux/nginx_php-5.2.17/include/php/TSRM -I/www/wdlinux/nginx_php-5.2.17/include/php/Zend -I/www/wdlinux/nginx_php-5.2.17/include/php/ext -I/www/wdlinux/nginx_php-5.2.17/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /root/phpredis-develop/redis.c -o redis.lo
  116. cc -I. -I/root/phpredis-develop -DPHP_ATOM_INC -I/root/phpredis-develop/include -I/root/phpredis-develop/main -I/root/phpredis-develop -I/www/wdlinux/nginx_php-5.2.17/include/php -I/www/wdlinux/nginx_php-5.2.17/include/php/main -I/www/wdlinux/nginx_php-5.2.17/include/php/TSRM -I/www/wdlinux/nginx_php-5.2.17/include/php/Zend -I/www/wdlinux/nginx_php-5.2.17/include/php/ext -I/www/wdlinux/nginx_php-5.2.17/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/phpredis-develop/redis.c  -fPIC -DPIC -o .libs/redis.o
  117. env: cc: Permission denied
  118. make: *** [redis.lo] Error 1
  119. [root@iZ25x4ajoqbZ phpredis-develop]#
复制代码

make失败,怎么回事
cn

TOP

真的价格真的价格
pinhao.cn

TOP

回复 7# aming511


   我进入桌面环境运行就正常了!

TOP

本帖最后由 winran 于 2017-2-26 17:34 编辑

最新稳定版下载redis:
  
wget   http://download.redis.io/releases/redis-3.2.8.tar.gz
  
tar  -zxvf redis-3.2.8.tar.gz
  
cd  redis-3.2.8
  
make
  
make  install
分子图

TOP

本帖最后由 aming511 于 2017-2-24 16:58 编辑

回复 11# Terabyte


   我配置也出现同样的问题, 确定过目录啊。可还是不对啊。
checking build system type... Invalid configuration `/www/wdlinux/nginx_php-5.6.29/bin/php-config': machine `/www/wdlinux/nginx_php-5.6.29/bin/php' not recognized
configure: error: /bin/sh ./config.sub /www/wdlinux/nginx_php-5.6.29/bin/php-config failed
我就是我

TOP

请大家注意, 安装Redis的时候千万要设置密码,最好是缺省端口也改一改。因为Redis本身的漏洞,不设置的话会被扫描而种入病毒、木马。

对于楼主在步骤e写的:
--------------------------------------------------------
im  /etc/redis/6379.conf
//找到bind 127.0.0.1这一行,替换成下面这行内容
bind  0.0.0.0

--------------------------------------------------------
请一定一定一定要谨慎,如果只是本机调用,建议改成bind 127.0.0.1即可
同时一定一定一定要在大约481行设置:
requirepass 你的密码

如果突然CPU长时间接近100%,而且查看进程发现有类似这些进程:
AnXqV, ddg.219, ddg.212, minerd

再看看这些目录下是不是多了东西:/opt, /tmp,/var/spool/cron, /etc/rc.d/

那么恭喜你中奖了, 服务器已经沦为挖矿肉鸡。

TOP

回复 6# skyuser


看起来是PHP的安装目录路径不对。
仔细看看具体路径,替换一下。

TOP

回复 4# bluegua


   请教一下怎么防止这个呢? 谢谢

TOP

二、添加phpredis扩展






配置php-config的时候报错 能帮我看看是怎么回事吗?

checking buil ...
skyuser 发表于 2017-2-13 23:37

你解决了嘛?  我也卡在这里呢。
我就是我

TOP

我的也是楼上一样的问题,请问怎么解决呢~~~~  :'( :'( :'(
我就是我

TOP

请问,为什么我执行到第二步同make 就不能进行了呢?  make: *** No targets specified and no makefile found.  Stop.    提示这个~~  第一步的一切正常。

TOP

本帖最后由 skyuser 于 2017-2-13 23:38 编辑

二、添加phpredis扩展

  1. /www/wdlinux/apache_php-5.6.29/bin/phpize


  2. ./configure --with-php-config= /www/wdlinux/apache_php-5.6.29/bin/php-config
复制代码





配置php-config的时候报错 能帮我看看是怎么回事吗?

checking build system type... Invalid configuration `/www/wdlinux/apache_php-5.6.29/bin/php-config': machine `/www/wdlinux/apache_php-5.6.29/bin/php' not recognized
configure: error: /bin/sh ./config.sub /www/wdlinux/apache_php-5.6.29/bin/php-config failed

TOP

在步骤a编译过程中,如果出现错误:
../deps/jemalloc/lib/libjemalloc.a(nstime.o): In function nstime_get': /opt/redis_src/current/redis-stable/deps/jemalloc/src/nstime.c:120: undefined reference toclock_gettime'

在以下文件redis-stable\src\Makefile中这一行的最后加入 -lrt,即
FINAL_LIBS+= ../deps/jemalloc/lib/libjemalloc.a -lrt

重新编译即可。
问题参考:
https://github.com/antirez/redis/issues/3790

TOP

返回列表