phpredis 擴充安裝

來源:互聯網
上載者:User

一 下載:git上下載redis的擴充包

git clone https://github.com/nicolasff/phpredis

二 掛載:在shell中輸入 phpize 【查看適合的版本資訊】

 ./configure 編譯

【phpize是用來擴充php擴充模組的,通過phpize可以建立php的外掛模組】

注意:(phpize 如果包含多個php,必須指定位置)

cuihuan:phpredis cuixiaohuan$ phpizeConfiguring for:PHP Api Version:         20121113Zend Module Api No:      20121212Zend Extension Api No:   220121212Cannot find autoconf. Please check your autoconf installation and the$PHP_AUTOCONF environment variable. Then, rerun this script.

報錯的話需要安裝:brew install autoconf [phpize 報錯] 否則沒有phpize

[work@cuixiaozhuai phpredis]$ phpize        Configuring for:PHP Api Version:         20041225Zend Module Api No:      20060613Zend Extension Api No:   220060519[work@cuixiaozhuai phpredis]$ ./configure

當存在多個版本的php的時候,需要指定設定檔

 ./configure --with-php-config=/home/work/thirdparty/php5/bin/php-config 

三 安裝: make 之後make test 最好 make install

Build complete.Don't forget to run 'make test'.cuihuan:phpredis cuixiaohuan$ make test

四 問題報錯修複:【已修複,但是原因可能不太準確】

make編譯報錯

.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 herecollect2: ld returned 1 exit statusmake: *** [redis.la] Error 1

最初以為是php多個版本產生install問題,採用./configure 指定php版本,指定php位置。
但是效果還是有問題。
最終通過修改redis_cluester.c 中,注釋掉了這兩個重複的

  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 ZEND_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();  58 */    

五 進行簡單的php操作測試

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');

回複內容:

一 下載:git上下載redis的擴充包

git clone https://github.com/nicolasff/phpredis

二 掛載:在shell中輸入 phpize 【查看適合的版本資訊】

 ./configure 編譯

【phpize是用來擴充php擴充模組的,通過phpize可以建立php的外掛模組】

注意:(phpize 如果包含多個php,必須指定位置)

cuihuan:phpredis cuixiaohuan$ phpizeConfiguring for:PHP Api Version:         20121113Zend Module Api No:      20121212Zend Extension Api No:   220121212Cannot find autoconf. Please check your autoconf installation and the$PHP_AUTOCONF environment variable. Then, rerun this script.

報錯的話需要安裝:brew install autoconf [phpize 報錯] 否則沒有phpize

[work@cuixiaozhuai phpredis]$ phpize        Configuring for:PHP Api Version:         20041225Zend Module Api No:      20060613Zend Extension Api No:   220060519[work@cuixiaozhuai phpredis]$ ./configure

當存在多個版本的php的時候,需要指定設定檔

 ./configure --with-php-config=/home/work/thirdparty/php5/bin/php-config 

三 安裝: make 之後make test 最好 make install

Build complete.Don't forget to run 'make test'.cuihuan:phpredis cuixiaohuan$ make test

四 問題報錯修複:【已修複,但是原因可能不太準確】

make編譯報錯

.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 herecollect2: ld returned 1 exit statusmake: *** [redis.la] Error 1

最初以為是php多個版本產生install問題,採用./configure 指定php版本,指定php位置。
但是效果還是有問題。
最終通過修改redis_cluester.c 中,注釋掉了這兩個重複的

  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 ZEND_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();  58 */    

五 進行簡單的php操作測試

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');
  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.