Background: After installing redis, you need to install the phpredis extension to allow PHP to operate redis; this machine has multiple PHP versions. Let me share the pitfalls encountered during the installation process.
1 download
Download the redis expansion package on git
- git clone https://github.com/nicolasff/phpredis
-
Copy the code
2 Mount and configure
Enter phpize in the shell [Note: multiple php versions need to be specified]
[phpize is used to extend php extension modules, and php can be built through phpize Plug-in module】
Note: (If phpize contains multiple php, the location must be specified)
- cuihuan:phpredis cuixiaohuan$ ../php/bin/phpize
- Configuring for:
- PHP Api Version: 20121113
- Zend Module Api No: 20121212
- Zend Extension Api No: 220121212
- Cannot find autoconf. Please check your autoconf installation and the
- $PHP_AUTOCONF environment variable. Then, rerun this script. Report error] Otherwise there is no phpize
-
[work@cuixiaozhuai phpredis]$ ../php/bin/phpize Configuring for:PHP Api Version: 20041225 Zend Module Api No: 20060613Zend Extension Api No: 22006 0519 [work@cuixiaozhuai phpredis]$ ./configure --with-php-config=/home/work/thirdparty/php5/bin/php-config
-
-
- Copy code
-
-
- When there are multiple versions of php , need to specify the configuration file
-
./configure --with-php-config=/home/work/thirdparty/php5/bin/php-config
Copy the code Three compilation and installation
After - make, it is best to make test
- make install
cuihuan:phpredis cuixiaohuan$ make. . . Build complete. Don't forget to run 'make test'.
cuihuan:phpredis cuixiaohuan$ make test cuihuan:phpredis cuixiaohuan$ make install-
-
-
- Copy code
-
- Four Problem fixes
- 【Fixed, but the reason may not be accurate】
- make compile error
.libs/redis_cluster.o(.data.rel.local+0x0): In function `ht_free_seed':/home/work/ thirdparty/php5/php5/phpredis/redis_cluster.c:226: multiple definition of `arginfo_scan' .libs/redis.o(.data.rel.local+0xe0):/home/work/thirdparty/php5/php5/p hpredis/redis.c:452: first defined here /usr/bin/ld: Warning: size of symbol `arginfo_scan' changed from 160 in .libs/redis.o to 200 in .libs/redis_cluster.o.libs/ redis_cluster.o(.data.rel.local+0xe0): In function `create_cluster_context': /home/work/thirdparty/php5/php5/phpredis/redis_cluster.c:276: multiple definition of `arginfo_kscan' .libs/ redis.o(.data.rel.local+0x0):/home/work/thirdparty/php5/php5/phpredis/redis.c:364: first defined here- collect2: ld returned 1 exit status
- make: *** [redis.la] Error 1
-
-
-
- Copy code
-
-
- At first, I thought it was an installation problem generated by multiple versions of PHP. Use ./configure to specify the PHP version and PHP location.
- But the effect is still problematic.
Finally, by modifying redis_cluester.c, these two duplicates were commented out
40
41 /* Argument info for HSCAN, SSCAN, HSCAN */
42 /*ZEND_BEGIN_ARG_INFO_EX(arginfo_kscan, 0, 0 , 2) 43 ZEND_ARG_INFO(0, str_key)-
- 44 ZEND_ARG_INFO(1, i_iterator)
-
- 45 ZEND_ARG_INFO(0, str_pattern)
-
- 46 ZEND_ARG_INFO(0, i_count)
-
- 47 Z END_END_ARG_INFO();
-
- 48 * /
-
- 49
-
- 50 /* Argument infor for SCAN */
-
- 51 /*
-
- 52 ZEND_BEGIN_ARG_INFO_EX(arginfo_scan, 0, 0, 2)
-
- 53 ZEND_ARG_INFO(1, i_iterator)
-
- 54 ZEND_ARG_INFO(0, str_node )
-
-
-
- 55 ZEND_ARG_INFO (0, Str_pattern)
-
- 56 ZEND_ARG_INFO (0, I_Count)
-
- 57 ZEND_END_ARG_INFO ();五 简单测试
- $redis = new Redis();
- $conn = $redis->connect('127.0.0.1',6379);
-
- echo "redis pass and status show";
- var_dump($redis->ping());
-
- $redis->set('test_key','test_value');
- echo "test set val=".$redis->get('test_key')."";
-
- $redis->setnx('unique_key',"unique_val");
- $redis->setnx('unique_key',"unique_val_2");
-
- echo $redis->get("unique_key");
-
- sleep(60);
- echo 'is exist'.$redis->exists('test_60s');
- echo 'not has value'.$redis->get('test_60s');
- $redis->delete('test_key','test_60s');
-
复制代码
个人小站原文链接
|