PHP CURL 启用 Linux
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8014482/
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
PHP CURL Enable Linux
提问by jcmitch
I have some php scripts that I've been running on an Apache server on a windows machine. These scripts use curl which isn't enabled by default in php. For windows enabling it was as easy and un-commenting the line with the curl .dll file in the php.ini file. Well since Linux uses .so instead of .dll files that wont work.
我有一些 php 脚本,它们一直在 Windows 机器上的 Apache 服务器上运行。这些脚本使用在 php 中默认未启用的 curl。对于 Windows 启用它很简单,并且在 php.ini 文件中使用 curl .dll 文件取消注释行。好吧,因为 Linux 使用 .so 而不是无法工作的 .dll 文件。
Does anyone have any idea how to enable curl on an Apache server running on a Linux machine? Php is already installed so I'm really hoping for a solution that doesn't involve re-installing php. Thanks in advance!
有谁知道如何在 Linux 机器上运行的 Apache 服务器上启用 curl?Php 已经安装,所以我真的希望有一个不涉及重新安装 php 的解决方案。提前致谢!
Edit: The machine has the openSUSE v11.3 version of linux installed. I'm didn't setup the machine and am interacting with it over command line(putty). Any help would be great.
编辑:机器安装了 openSUSE v11.3 版本的 linux。我没有设置机器,而是通过命令行(腻子)与它进行交互。任何帮助都会很棒。
采纳答案by ono2012
If anyone else stumbles onto this page from google like I did:
如果其他人像我一样从谷歌偶然发现这个页面:
use putty (putty.exe) to sign into your server and install curl using this command :
使用 putty (putty.exe) 登录您的服务器并使用以下命令安装 curl:
sudo apt-get install php5-curl
Make sure curl is enabled in the php.ini file. For me it's in /etc/php5/apache2/php.ini, if you can't find it, this line might be in /etc/php5/conf.d/curl.ini. Make sure the line :
确保在 php.ini 文件中启用了 curl。对我来说,它在/etc/php5/apache2/php.ini 中,如果你找不到它,这一行可能在/etc/php5/conf.d/curl.ini 中。确保该行:
extension=curl.so
is not commented out then restart apache, so type this into putty:
没有注释掉然后重启apache,所以在putty中输入:
sudo /etc/init.d/apache2 restart
Info for install from https://askubuntu.com/questions/9293/how-do-i-install-curl-in-php5, to check if it works this stack overflow might help you: Detect if cURL works?
来自https://askubuntu.com/questions/9293/how-do-i-install-curl-in-php5 的安装信息,检查它是否有效这个堆栈溢出可能对你有帮助:检测 cURL 是否有效?
回答by andreapier
It dipends on which distribution you are in general but... You have to install the php-curl module and then enable it on php.ini like you did in windows. Once you are done remember to restart apache demon!
它取决于您通常使用的发行版,但是...您必须安装 php-curl 模块,然后像在 Windows 中一样在 php.ini 上启用它。完成后记得重新启动 apache 恶魔!
回答by Salim
I used the previous installation instruction on Ubuntu 12.4, and the php-curl module is successfully installed, (php-curl used in installing WHMCS billing System):sudo apt-get install php5-curl
sudo /etc/init.d/apache2 restart
我在Ubuntu 12.4上使用了之前的安装说明,成功安装了php-curl模块,(安装WHMCS计费系统时使用的php-curl):sudo apt-get install php5-curl
sudo /etc/init.d/apache2 restart
By the way the below line is not added to /etc/php5/apache2/php.ini config file as it's already mentioned:
extension=curl.so
顺便说一下,下面的行没有添加到 /etc/php5/apache2/php.ini 配置文件中,因为它已经提到了:
extension=curl.so
In addition the CURL module figures in http://localhost/phpinfo.php
Best,
此外,CURL 模块在http://localhost/phpinfo.php
Best 中占有一席之地,
回答by Raghwendra Pathak
if you have used curl above the page and below your html is present and unfortunately your html page is not able to view then just enable your curl. But in order to check CURL is enable or not in php you need to write following code:
如果您在页面上方和 html 下方使用了 curl,但不幸的是您的 html 页面无法查看,那么只需启用您的 curl。但是为了在 php 中检查 CURL 是否启用,您需要编写以下代码:
echo 'Curl: ', function_exists('curl_version') ? 'Enabled' : 'Disabled';
回答by Thamaraiselvam
add this line end of php.ini
添加此行末尾 php.ini
openssl.cafile=/opt/lampp/share/curl/curl-ca-bundle.crt
may be curl path cannot be identified by PHP
可能是 PHP 无法识别 curl 路径
回答by Frank
If it's php 7 on ubuntu, try this
如果它是 ubuntu 上的 php 7,试试这个
apt-get install php7.0-curl
/etc/init.d/apache2 restart