search
Homephp教程php手册linux下php扩展curl的安装

linux下php扩展curl的安装

Jun 06, 2016 am 09:51 AM
curllinuxphp extensioncodeInstallOpen sourceprogrammingprogramming languagesoftware development

【参考资料】http://blog.csdn.net/qingflyer/article/details/6546071

方法一

安装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

第一种方法试了N遍一直在失败中,于是放弃。

使用第二种方法安装,

phpize提示找不到,其实命令在/usr/local/php/bin/目标下:

# /usr/local/php/bin/phpize

./configure --with-curl=DIR需要指定php的配置路径,应该如下:

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

注:上面的资料中错把--with-php-config写成了--with-php-php-config

然后就是编译安装:

# make
# make install
到这里会提示生成文件curl.so的路径: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/

进入到这个路径下,复制curl到extension_dir目录下(本目录路径可以看phpinfo可是直接看php.int),

修改php.ini

extension=curl.so

# /usr/local/php/bin/php -m
如果看到有curl项表示成功。

重启apache

# /usr/local/apache2/bin/apachectl stop

# /usr/local/apache2/bin/apachectl start

到此成功了,在phpinfo中可以看到CURL的项。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function