php 如何启用 curl,已安装的 Ubuntu LAMP 堆栈?

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

How to enable curl, installed Ubuntu LAMP stack?

phpubuntucurllamp

提问by Arshdeep

I have installed ubuntu Lamp stack. But the curl is not enabled, neither can I can find the extension listed in the INI file. I added manually but it didn't work either.

我已经安装了 ubuntu Lamp 堆栈。但是没有启用 curl,我也找不到 INI 文件中列出的扩展名。我手动添加但它也不起作用。

How should I enable Curl then?

那么我应该如何启用 Curl?

回答by rabidmachine9

From http://buzznol.blogspot.com/2008/12/install-curl-extension-for-php-in.html:

来自http://buzznol.blogspot.com/2008/12/install-curl-extension-for-php-in.html

sudo apt-get install php5-curl

After installing libcurl you should restart the web server with one of the following commands,

安装 libcurl 后,您应该使用以下命令之一重新启动 Web 服务器,

sudo /etc/init.d/apache2 restartOR sudo service apache2 restart

sudo /etc/init.d/apache2 restart或者 sudo service apache2 restart

回答by Van Luu

You only have to install the php5-curl library. You can do this by running

您只需要安装 php5-curl 库。你可以通过运行来做到这一点

sudo apt-get install php5-curl

Click herefor more information.

单击此处了解更多信息。

回答by Димитър Илиев

Try sudo apt-get install php-curlit worked on fresh Ubuntu 16.04 LTS, with lamp-server and php7. I tried with php7-curl- didn't work and also didn't work with php5-curl

尝试 sudo apt-get install php-curl在带有灯服务器和 php7 的全新 Ubuntu 16.04 LTS 上运行。我试过php7-curl- 没有用,也没有用php5-curl

回答by Burak Tokak

For those, who is trying to install php-curl on PHP 7, will get an error. Actually if you are installing php-curl in PHP 7, the package name should be;

对于那些试图在 PHP 7 上安装 php-curl 的人来说,会得到一个错误。实际上,如果你在 PHP 7 中安装 php-curl,包名应该是;

sudo apt-get install php-curl

Not php5-curlor php7-curl, just php-curl.

不是php5-curlphp7-curl,只是php-curl

回答by codeNeverDie

First thing to do : Check for the PHP Vesion your machine is running.

要做的第一件事:检查您的机器正在运行的 PHP 版本。

command Line :php -version

命令行 :php -version

This will show something like this (in my case) :

这将显示如下内容(在我的情况下):

PHP 7.0.8-0ubuntu0.16.04.3 (cli) ( NTS ) Copyright (c) 1997-2016 The PHP Group

PHP 7.0.8-0ubuntu0.16.04.3 (cli) ( NTS ) 版权所有 (c) 1997-2016 The PHP Group

if : you are using PHP 5.x.x => run command : sudo apt-get install php5-curl

如果:您正在使用 PHP 5.xx => 运行命令: sudo apt-get install php5-curl

if : PHP 7.x.x => run command (in may case) : sudo apt-get install php7.0-curl

如果:PHP 7.xx => 运行命令(在可能的情况下): sudo apt-get install php7.0-curl

Enable this extention by runing :

通过运行启用此扩展:

sudo gedit /etc/php/7.0/cli/php.ini

and in the file "php.ini": search for keyword "curl" to find this line Below and change it from

并在文件“php.ini”中:搜索关键字“curl”以找到下面的这一行并将其从

;extension=php_curl.dll

;扩展= p​​hp_curl.dll

To:

到:

extension=php_curl.dll

扩展名=php_curl.dll

Next, save your file "php.ini".

接下来,保存您的文件“php.ini”。

Finally, In your command line restart your server by running : sudo service apache2 restart.

最后,在您的命令行中运行 : 重新启动您的服务器sudo service apache2 restart

回答by Kailas

Fire the below command it give list of modules

触发下面的命令,它给出模块列表

 sudo apt-cache search php5-

Then file fire below command with module name to be install

然后在命令下面使用要安装的模块名称文件 fire

 sudo apt-get install name of the module

For reference link

供参考链接

回答by Slycreator

I tried most of the above but it didnt work for my machine.ubuntu 18.04 but what worked for me is this.

我尝试了上述大部分方法,但它对我的 machine.ubuntu 18.04 不起作用,但对我有用的是这个。

first: check your php version

第一:检查你的php版本

$ php-version

second: add your php version to the command ,mine was

第二:将您的 php 版本添加到命令中,我的是

  $ sudo apt-get install php7.2-curl

lastly restart apache server

最后重启apache服务器

sudo service apache2 restart

although most person claimed that it not necessarily to restart apache :) thanks

尽管大多数人声称不一定要重新启动 apache :) 谢谢

回答by Danielprabhakaran N

Don't have to give version numbers. Just run sudo apt-get install php-curl.It worked for me. Don't forgot to restartthe server. sudo service apache2 restart

不必提供版本号。只需运行 sudo apt-get install php-curl。它对我有用。不要忘记重新启动服务器。 须藤服务 apache2 重启

回答by eluleci

Try this:

尝试这个:

sudo apt-get install -y curl