从网上 down 了一个 curl-7.17.1.tar.gz ,解压/编译:
cd /home/moky/downloads/curl-7.17.1
./configure --prefix=/usr/local/curl --with-ssl
提示未安装 openssl
于是又 down 了一个 openssl-1.0.0-beta3.tar.gz ,解压/编译:
cd /home/moky/downloads/openssl-1.0.0-beta3
./config --prefix=/usr/local/ssl
#./config --prefix=/usr/local --openssldir=/usr/local/openssl
编译通过
再次编译 curl 的时候提示 configure: error: OpenSSL libs and/or directories were not found where specified!
重新尝试了几种方式编译 openssl ,问题未解决
后来查到官方解析说这是由于 gnu autoconf tool 的 bug 引起,而非 curl 的原因,编译需指定 openssl 的库安装目录:
./configure --prefix=/usr/local/curl --with-ssl --with-zlib=/usr/local/zlib2 CFLAGS=-I/usr/local/ssl/include CPPFLAGS=-I/usr/local/ssl/include PKG_CONFIG_PATH=/usr/local/ssl/lib/pkgconfig LDFLAGS=-L/usr/local/ssl/lib
编译通过
最后编译 php 的 curl 扩展:
cd /home/moky/downloads/php-5.2.9/ext/curl
./configure --with-php-config=/usr/local/php/bin/php-config --with-curl=/usr/local/curl
然后打开 /etc/php.ini ,找到 extensions_dir 所指向的目录,将刚刚编译好的 curl.so (在当前目录的 modules 子目录中) cp 过去,并在 php.ini 中将 extention=curl.so 前面的分号去掉
保存退出,重启 apache