php5.2 mysqli,php 5.2.3+mysqli 安装 总结

本文详细介绍了在编译PHP扩展mysqli时遇到的错误,包括'MYSQL_RPL_MASTER'未声明和'gptr'未定义的问题,以及解决这些问题的步骤。通过修改相关源文件并重新编译,最终成功安装mysqli扩展并加载到PHP中。
摘要由CSDN通过智能技术生成

记得原来在编译php的已经已经加上参数

--with-mysql=/usr/local/mysql \

--with-mysqli=/usr/local/mysql/bin/mysql_config \

可后来找了一个,的确不存在mysqli.so,所以只能单独来编译mysqli了。

mysqli是优化过的mysql函数库,MYSQL版本不能低于4.1.12

cd /root/tmp/php-5.2.3/ext/mysqli

#####进入到mysqli的目录。

再用phpize生成configure文件:

/usr/local/bin/phpize

Configuring for:

PHP Api Version:         20041225

Zend Module Api No:      20060613

Zend Extension Api No:   220060519

#./configure --prefix=/usr/local/mysqli --with-php-config=/usr/local/bin/php-config --with-mysqli=/usr/bin/mysql_config

make

make install

Installing shared extensions:     /usr/local/lib/php/extensions/debug-non-zts-20060613/

然后在/usr/local/lib/php.ini

加上一句:

extension=/usr/local/lib/php/extensions/no-debug-non-zts-20060613/mysqli.so

重新启动apache即可看到已经加载mysqli成功。

1、如果出现出错代码:

/root/tmp/php-5.2.3/ext/mysqli/mysqli.c: In function 'zm_startup_mysqli':

/root/tmp/php-5.2.3/ext/mysqli/mysqli.c:637: error: 'MYSQL_RPL_MASTER' undeclared (first use in this function)

/root/tmp/php-5.2.3/ext/mysqli/mysqli.c:637: error: (Each undeclared identifier is reported only once

/root/tmp/php-5.2.3/ext/mysqli/mysqli.c:637: error: for each function it appears in.)

/root/tmp/php-5.2.3/ext/mysqli/mysqli.c:638: error: 'MYSQL_RPL_SLAVE' undeclared (first use in this function)

/root/tmp/php-5.2.3/ext/mysqli/mysqli.c:639: error: 'MYSQL_RPL_ADMIN' undeclared (first use in this function)

*** Error code 1

修改一下这个文件就可以

cd /usr/include/mysql

root@www[/usr/include/mysql]# vi mysql.h

在第221行

... ...

enum mysql_protocol_type

{

MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,

MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY

};

/*

There are three types of queries - the ones that have to go to

the master, the ones that go to a slave, and the adminstrative

type which must happen on the pivot connectioin

*/

#添加下面的4行

enum mysql_rpl_type

{

MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, MYSQL_RPL_ADMIN

};

2、如果出现以下错误:

/root/tmp/php-5.2.3/ext/mysqli/mysqli_api.c: In function 'zif_mysqli_stmt_bind_param':

/root/tmp/php-5.2.3/ext/mysqli/mysqli_api.c:144: error: 'gptr' undeclared (first use in this function)

/root/tmp/php-5.2.3/ext/mysqli/mysqli_api.c:144: error: (Each undeclared identifier is reported only once

/root/tmp/php-5.2.3/ext/mysqli/mysqli_api.c:144: error: for each function it appears in.)

/root/tmp/php-5.2.3/ext/mysqli/mysqli_api.c: In function 'zif_mysqli_stmt_execute':

/root/tmp/php-5.2.3/ext/mysqli/mysqli_api.c:603: error: 'gptr' undeclared (first use in this function)

make: *** [mysqli_api.lo] 错误 1

修改一下这个文件就可以

vi mysqli_api.c

查找所有gptr,有四处分别位于行144、行150、行603、行607,以 char* 替换

测试Mysqli运行状况:

Vim mysqli.php

$mysqli = new mysqli("localhost", "my_user", "my_password", "dbname");

/* check connection */

if (mysqli_connect_errno()) {

printf("Connect failed: %s\n", mysqli_connect_error());

exit();

}

printf("Host information: %s\n", $mysqli->host_info);

/* close connection */

$mysqli->close();

?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值