无法使用自定义路径的libcurl编译PHP-CURL扩展求助
各位好,我遇到了编译PHP curl扩展的棘手问题,想请大家帮忙支招:
我已经在服务器的/usr/local/curl-7.88.1/路径下安装了libcurl,现在想为PHP 8.1.12编译对应的curl扩展,操作步骤如下:
进入PHP源码包的curl扩展目录:
cd /usr/src/php-8.1.12/ext/curl/运行phpize初始化编译环境:
/usr/local/php81/bin/phpize输出的配置信息如下:
Configuring for:
PHP Api Version: 20210902
Zend Module Api No: 20210902
Zend Extension Api No: 420210902执行configure命令,明确指定php-config路径和自定义的libcurl路径:
./configure --with-php-config=/usr/local/php81/bin/php-config --with-curl=/usr/local/curl-7.88.1/
但执行到这一步就报错了,具体错误信息如下:
checking for cURL support... yes, shared
checking for libcurl >= 7.29.0... no
configure: error: Package requirements (libcurl >= 7.29.0) were not met:No package 'libcurl' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.Alternatively, you may set the environment variables CURL_CFLAGS
and CURL_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
我尝试过设置CFLAGS和LDFLAGS环境变量,指向自定义libcurl的头文件和库文件路径,但还是会报同样的错误。另外如果我用yum install libcurl-devel安装系统自带的libcurl开发包,configure能成功执行,但它会直接忽略我指定的--with-curl=/usr/local/curl-7.88.1/参数,转而使用系统自带的旧版本libcurl,这并不是我想要的结果。
有没有大佬知道怎么让configure正确识别我自定义路径下的libcurl呢?
备注:内容来源于stack exchange,提问作者Nick

