Linux 用curl编译php,curl安装在哪里?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4976971/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Compiling php with curl, where is curl installed?
提问by HyderA
I need to specify a directory when compiling php with --with-curl=
我需要在编译php时指定一个目录 --with-curl=
The curl binary is located at /usr/bin/curl
curl 二进制文件位于 /usr/bin/curl
curl -V
gives me
curl -V
给我
curl 7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
locate curl
gives me
locate curl
给我
/usr/bin/curl
/usr/lib/libcurl.so.3
/usr/lib/libcurl.so.3.0.0
/usr/lib64/libcurl.so.3
/usr/lib64/libcurl.so.3.0.0
removed /usr/share/... and other irrelevant files
删除了 /usr/share/... 和其他不相关的文件
UPDATE
更新
Tried --with-curl=/usr/lib64
and --with-curl=/usr/lib
although I'm pretty sure it's 64 bit.
尝试过--with-curl=/usr/lib64
,--with-curl=/usr/lib
虽然我很确定它是 64 位的。
checking for cURL support... yes
checking if we should use cURL for url streams... no
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
SOLUTION
解决方案
PHP requires curl-devel
PHP 需要 curl-devel
采纳答案by netcoder
None of these will allow you to compile PHP with cURL enabled.
这些都不允许您在启用 cURL 的情况下编译 PHP。
In order to compile with cURL, you need libcurl header files (.h files). They are usually found in /usr/include/curl
. They generally are bundled in a separate developmentpackage.
为了使用 cURL 进行编译,您需要 libcurl 头文件(.h 文件)。它们通常位于/usr/include/curl
. 它们通常捆绑在单独的开发包中。
Per example, to install libcurl in Ubuntu:
例如,要在 Ubuntu 中安装 libcurl:
sudo apt-get install libcurl4-gnutls-dev
Or CentOS:
或 CentOS:
sudo yum install curl-devel
Then you can just do:
然后你可以这样做:
./configure --with-curl # other options...
If you compile cURL manually, you can specify the path to the files without the lib
or include
suffix. (e.g.: /usr/local
if cURL headers are in /usr/local/include/curl
).
如果手动编译 cURL,则可以指定不带lib
或include
后缀的文件路径。(例如:/usr/local
如果 cURL 标头在 中/usr/local/include/curl
)。
回答by Bob Fanger
If you're going to compile a 64bit version(x86_64) of php use: /usr/lib64/
如果您要编译64 位版本(x86_64) 的 php,请使用: /usr/lib64/
For architectures (i386 ... i686) use /usr/lib/
对于体系结构 (i386 ... i686) 使用 /usr/lib/
I recommend compiling php to the same architecture as apache. As you're using a 64bit linux i asume your apache is also compiled for x86_64.
我建议将 php 编译为与 apache 相同的架构。当您使用 64 位 linux 时,我假设您的 apache 也是为 x86_64 编译的。
回答by Rob Williams
Try just --with-curl, without specifying a location, and see if it'll find it by itself.
试试 --with-curl,不指定位置,看看它是否会自己找到它。
回答by bourneli
php curl lib is just a wrapper of cUrl, so, first of all, you should install cUrl. Download the cUrl source to your linux server. Then, use the follow commands to install:
php curl lib 只是 cUrl 的包装器,因此,首先,您应该安装 cUrl。将 cUrl 源下载到您的 linux 服务器。然后,使用以下命令进行安装:
tar zxvf cUrl_src_taz
cd cUrl_src_taz
./configure --prefix=/curl/install/home
make
make test (optional)
make install
ln -s /curl/install/home/bin/curl-config /usr/bin/curl-config
Then, copy the head files in the "/curl/install/home/include/" to "/usr/local/include". After all above steps done, the php curl extension configuration could find the original curl, and you can use the standard php extension method to install php curl.
Hope it helps you, :)
然后,将“/curl/install/home/include/”中的头文件复制到“/usr/local/include”。完成以上步骤后,php curl扩展配置就可以找到原来的curl了,就可以使用标准的php扩展方法安装php curl了。
希望对你有帮助,:)
回答by Usman Shaukat
For Ubuntu 17.0 +
对于 Ubuntu 17.0 +
Adding to @netcoder answer above, If you are using Ubuntu 17+, installing libcurl header files is half of the solution. The installation path in ubuntu 17.0+ is different than the installation path in older Ubuntu version. After installing libcurl, you will still get the "cURL not found" error. You need to perform one extra step (as suggested by @minhajul in the OP comment section).
添加到上面的@netcoder 答案,如果您使用的是 Ubuntu 17+,安装 libcurl 头文件是解决方案的一半。ubuntu 17.0+ 中的安装路径与旧版 Ubuntu 中的安装路径不同。安装 libcurl 后,您仍然会收到“cURL not found”错误。您需要执行一个额外的步骤(如 OP 评论部分中的@minhajul 所建议的那样)。
Add a symlink in /usr/include of the cURL installation folder (cURL installation path in Ubuntu 17.0.4 is /usr/include/x86_64-linux-gnu/curl).
在 cURL 安装文件夹的 /usr/include 中添加符号链接(Ubuntu 17.0.4 中的 cURL 安装路径为 /usr/include/x86_64-linux-gnu/curl)。
My server was running Ubuntu 17.0.4, the commands to enable cURL support were
我的服务器运行的是 Ubuntu 17.0.4,启用 cURL 支持的命令是
sudo apt-get install libcurl4-gnutls-dev
Then create a link to cURL installation
然后创建一个 cURL 安装链接
cd /usr/include
sudo ln -s x86_64-linux-gnu/curl