php5 curl 扩展,Linux php5 curl 扩展

方法一

安装cURL

wget http://curl.haxx.se/download/curl-7.17.1.tar.gz

tar -zxf curl-7.17.1.tar.gz

./configure --prefix=/usr/local/curl

make & make install

安装php

只要打开开关 --with-curl=/usr/local/curl

就可以了。

这个扩展库还是非常棒,是fsockopen等等相关的有效的替代品。

方法二

进入安装原php的源码目录,

cd ext

cd curl

phpize

./configure --with-curl=DIR

make & make install

就会在PHPDIR/ext/curl/moudles/下生成curl.so的文件。

复制curl.so文件到extensions的配置目录,修改php.ini就好了

extension=curl.so

以上是网上找到的资料,下面是我在安装过程中遇到的问题,我用的第二个方法,因为我是在现在有的PHP扩展Curl模块。在phpize时找不到命令,因为我的PHP不是默认安装在,在lib库里没有找到这个命令,要绝对路径执行phpize

进入安装原php的源码目录,

cd ext

cd curl

#路径不一定在当前目录下,去寻找phpize运行。之后会生成了一个configure文件

/usr/local/php-5.3.3/phpize

执行完出看到有perl警告提示环境设置失败,原信息如下:

Configuring for:

PHP Api Version:         20041225

Zend Module Api No:      20060613

Zend Extension Api No:   220060519

perl: warning: Setting locale failed.

perl: warning: Please check that your locale settings:

LANGUAGE = (unset),

LC_ALL = (unset),

LANG = "zh_CN.GB2312;zh_CN.UTF-8;en_US;en_US.UTF-8"

are supported and installed on your system.

perl: warning: Falling back to the standard locale ("C").

perl: warning: Setting locale failed.

perl: warning: Please check that your locale settings:

LANGUAGE = (unset),

LC_ALL = (unset),

LANG = "zh_CN.GB2312;zh_CN.UTF-8;en_US;en_US.UTF-8"

are supported and installed on your system.

perl: warning: Falling back to the standard locale ("C").

这个问题解决方法,在profile里加配置,步骤如下:

vim /etc/profile

在profile最底加上export LC_ALL=C

保存退出

执行profile让它生效

source /etc/profile

再执行一次

/usr/local/php-5.3.3/phpize

再也没有警告提示

接着往下走,安装Curl

./configure --with-curl=DIR

这一步又出现问题,找不到php-conifg配置,加上php-config的路径:

./configure --with-php-php-config=/usr/local/php-5.3.3/bin/php-config --with-curl=DIR

make & make install

会在PHPDIR/lib/php/extensions/下生成curl.so的文件。

复制到extension_dir,修改php.ini

extension=curl.so

/usr/local/php-5.3.3/bin/php -m

看到了curl 扩展。

重启apache 生效。

知识补充:

phpize的作用可以这样理解:侦测环境,建立一个configure文件。必须在一个目录下去运行phpize。那么phpize就知道你的的环境是哪个目录,并且configure文件建立在该目录下。

假如你的服务器上安装了多个版本php,那么需要告诉phpize要建立基于哪个版本的扩展。通过使用--with-php-config=指定你使用哪个php版本。

比如:--with-php-config=/usr/local/php524/bin/php-config

php-config文件在是在php编译生成后(安装好),安装目录下的一个文件。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值