Linux 在 Ubuntu 11.10 上启用 cURL 的问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8675732/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 03:51:58  来源:igfitidea点击:

Trouble Enabling cURL on Ubuntu 11.10

phplinuxubuntucurl

提问by Afsheen Khosravian

I have installed curl:

我已经安装了 curl:

sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

and I have updated my php.ini file to include:

我已经更新了我的 php.ini 文件以包括:

extension=php_curl.dll

I check to see if curl is working with the following command:

我检查 curl 是否正在使用以下命令:

php -i | grep curl

and I receive the following message:

我收到以下消息:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/php_curl.dll' - /usr/lib/php5/20090626+lfs/php_curl.dll: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/sqlite.so' - /usr/lib/php5/20090626+lfs/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0 Additional .ini files parsed => /etc/php5/cli/conf.d/curl.ini, curl

PHP 警告:PHP 启动:无法加载动态库 '/usr/lib/php5/20090626+lfs/php_curl.dll' - /usr/lib/php5/20090626+lfs/php_curl.dll:无法打开共享对象文件:否这样的文件或目录在 Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/sqlite.so' - /usr/lib/php5/20090626+lfs/sqlite.so所以:无法打开共享对象文件:在第 0 行的未知中没有这样的文件或目录解析的其他 .ini 文件 => /etc/php5/cli/conf.d/curl.ini,curl

I also tested curl by creating a file called testCurl.php which contains the following:

我还通过创建一个名为 testCurl.php 的文件来测试 curl,该文件包含以下内容:

<?php
echo ‘<pre>';
var_dump(curl_version());
echo ‘</pre>';
?>

When I navigate to localhost/testCurl.php I get an error: HTTP Error 500

当我导航到 localhost/testCurl.php 时出现错误:HTTP Error 500

Can anyone help me to get curl working?

谁能帮我让 curl 工作?

采纳答案by hakre

You put the wrong info in your php.ini

您在 php.ini 中输入了错误的信息

extension=php_curl.dll

On Ubuntu/Unix that is

在 Ubuntu/Unix 上

extension=php_curl.so

.someans Shared Object, that is a dynamic librarythe error messages speaks of. On Windows that is .dll, you probably just mixed that.

.so表示Shared Object,即错误消息所说的动态库。在 Windows 上.dll,您可能只是混合了它。

And it appears you try to load sqlite.sowhich does not exists. Normally you don't need to change your php.ini file when you install libraries on Ubuntu via apt, because the package scripts take care of that thanks to the work of the package maintainers.

看来您尝试加载sqlite.so不存在的内容。通常,当您通过 apt 在 Ubuntu 上安装库时,您不需要更改 php.ini 文件,因为由于包维护者的工作,包脚本会处理这些问题。

回答by brianmaissy

Support for sqlite2 is removed from php5 I think, so sqlite.so is no longer available in the current version of the package. You can manually restore it from the natty packages (this worked for me):

我认为从 php5 中删除了对 sqlite2 的支持,因此当前版本的软件包中不再提供 sqlite.so。您可以从整洁的包中手动恢复它(这对我有用):

(https://lists.ubuntu.com/archives/ubuntu-server-bugs/2011-October/065547.html)

(https://lists.ubuntu.com/archives/ubuntu-server-bugs/2011-October/065547.html)

回答by Marcelo Agimóvel

If you'r using Ubuntu or have more than one php.ini you may face this problem of enabling extension=php_curl.dll.

如果您使用 Ubuntu 或有多个 php.ini,您可能会遇到启用 extension=php_curl.dll 的问题。

It's curious but I was facing this problem using UBUNTU. For some reason it was calling a .dll file, but linux uses .so files.

很好奇,但我在使用 UBUNTU 时遇到了这个问题。出于某种原因,它正在调用 .dll 文件,但 linux 使用 .so 文件。

First thing to do is echo phpinfo(); in a .php file to check what php.ini is getting loaded.

首先要做的是 echo phpinfo(); 在 .php 文件中检查正在加载的 php.ini。

Configuration File (php.ini) Path /etc/php/7.1/apache2 Loaded Configuration File /etc/php/7.1/apache2/something/php.ini

配置文件(php.ini)路径 /etc/php/7.1/apache2 加载的配置文件 /etc/php/7.1/apache2/something/php.ini

So if you change only in one file it may not have the correct effect.

因此,如果您仅在一个文件中进行更改,则可能不会产生正确的效果。

In my case whas in /etc/php/7.1/apache2/php.ini and CURL was calling this way: ;extension=curl.dll

在我的情况下, /etc/php/7.1/apache2/php.ini 和 CURL 以这种方式调用:;extension=curl.dll

Change to extension=curl.so

更改为 extension=curl.so

Save and restart apache: sudo systemctl restart apache2

保存并重启apache:sudo systemctl restart apache2