用到PHP的curl功能,发现服务器上的PHP并没有配置curl,进而查询PHP官方文档,得知编译PHP时需要带上 –with-curl参数,才能把curl模块编译进去。我现在PHP已经编译安装进服务器了,不想再重新编译了,于是参考下面有网友评论的办法,单独编译curl模块,然后make install。

1. 进到对应扩展目录

# cd /opt/modole/src/php-5.2.12/ext/curl

2. 调用phpize程序生成编译配置文件

# /opt/model/php/bin/phpize

3. 调用configure生成Makefile文件,然后调用make编译,make install安装

./configure -with-curl=/opt/modules/curl -with-php-config=/opt/modules/php/bin/php-config

报错:

configure: error: Please reinstall the libcurl distribution -
easy.h should be in /include/curl/

解决:好像是丢包了,yum install curl curl-devel

重新编译

出现:

checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h

好像成功了?

make make install

[root@localhost curl]# make install
Installing shared extensions: /opt/modules/php/lib/php/extensions/no-debug-non-zts-20131226/

安装成功

4.修改php配置文件

查看 curl.so文件是否安装到这个目录下
#ll /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
修改php扩展库目录
#vi /usr/local/php/lib/php.ini
extension_dir = “/opt/modules/php/lib/php/extensions/no-debug-non-zts-20131226/”;

#vim /usr/local/php/lib/php.ini

extension=curl.so

 

检测是否安装成功,输入:/usr/local/php/bin/php -m

如果看到有curl项表示成功。

例如:

[root@localhost no-debug-non-zts-20131226]# /opt/modules/php/bin/php -m
[PHP Modules]
Core
ctype
curl
date
dom
ereg
fileinfo
filter
hash
iconv
json
libxml
mbstring
pcre
PDO
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter