多php环境下phpredis扩展安装
一 下载
git上下载redis的扩展包
git clone https://github.com/nicolasff/phpredis
二 挂载和configure
在shell中输入 phpize 【注意:多个php版本的时候需要指定】
./configure
【phpize是用来扩展php扩展模块的,通过phpize可以建立php的外挂模块】
注意:(phpize 如果包含多个php,必须指定位置)
cuihuan:phpredis cuixiaohuan$ ../php/bin/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]$ ../php/bin/phpize Configuring for:PHP Api Version: 20041225Zend Module Api No: 20060613Zend Extension Api No: 220060519[work@cuixiaozhuai phpredis]$ ./configure --with-php-config=/home/work/thirdparty/php5/bin/php-config
当存在多个版本的php的时候,需要指定配置文件
./configure --with-php-config=/home/work/thirdparty/php5/bin/php-config
三 编译和安装
make 之后最好make test
make install
cuihuan:phpredis cuixiaohuan$ make。。。Build complete.Don't forget to run 'make test'.cuihuan:phpredis cuixiaohuan$ make testcuihuan:phpredis cuixiaohuan$ make install
四 问题修复
【已修复,但是原因可能不太准确】
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 $redis = new Redis(); $conn = $redis->connect('127.0.0.1',6379); echo "redis pass and status show</br>"; var_dump($redis->ping()); $redis->set('test_key','test_value'); echo "test set val=".$redis->get('test_key')."</br>"; $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');

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

In this article, we're going to explore the notification system in the Laravel web framework. The notification system in Laravel allows you to send notifications to users over different channels. Today, we'll discuss how you can send notifications ov
