简体   繁体   English

如何在PHP / XAMPP中启用cURL

[英]How to enable cURL in PHP / XAMPP

How do I enable cURL in PHP? 如何在PHP中启用cURL?

​​

On Debian with Apache 2: 在使用Apache 2的Debian上:

apt-get install php5-curl
/etc/init.d/apache2 restart

(php4-curl if it's php4) (php4-curl如果是php4)

Since you're using XAMPP, uncomment the line 由于您正在使用XAMPP,请取消注释该行

;extension=php_curl.dll

in xampp\\apache\\bin\\php.ini , and then restart the Apache service. xampp\\apache\\bin\\php.ini ,然后重新启动Apache服务。

NB: In newer XAMPP versions, PHP has moved to root xampp folder xampp\\php\\php.ini . 注意:在较新的XAMPP版本中,PHP已移至root xampp文件夹xampp\\php\\php.ini

Steps for Windows 7: 适用于Windows 7的步骤:

  1. Ensure that the php.ini file that the PHP engine uses is the one you think it is. 确保PHP引擎使用的php.ini文件是您认为的那个。
  2. Ensure extension_dir in php.ini is correctly set to the ext folder 确保php.ini中的extension_dir正确设置为ext文件夹
  3. Ensure extension=php_curl.dll in the php.ini is uncommented 确保php.ini中的extension=php_curl.dll被取消注释

Finally and maybe the one most people don't know: 4. Ensure that there are these two files in the Windows System32 folder: libeay32.dll ssleay32.dll If not there, you may copy these two files from the php folder. 最后也许是大多数人不知道的:4。确保Windows System32文件夹中有这两个文件:libeay32.dll ssleay32.dll如果不存在,您可以从php文件夹中复制这两个文件。

I found the file located at: 我发现该文件位于:

C:\xampp\php\php.ini

Uncommented: 取消注释:

;extension=php_curl.dll

For Ubuntu (and probably all Debian-Based) Linux Distributions: 对于Ubuntu(可能还有所有基于Debian的)Linux发行版:

sudo apt-get install php5-curl
sudo /etc/init.d/apache2 restart 

You might have seen PHP Fatal error: Call to undefined function curl_init() before. 您可能已经看到PHP Fatal error: Call to undefined function curl_init()

In SUSE Linux : SUSE Linux中

zypper in php5-curl
rcapache2 restart

基本提示:在php.ini文件中启用CURL后,您需要重新启动Web服务器才能使其正常工作(我的经验说)。

由于XAMPP经过了一些修改,文件现在位于xampp/php/php.ini

实际上我是通过在xampp \\ apache \\ bin \\ php.ini文件中取消注释extension=php_curl.dll来实现的。

如果您正在使用MAMP ,则默认启用cURL

You can check phpinfo() (create a script containing and browse to it). 您可以检查phpinfo() (创建一个包含并浏览它的脚本)。 This will tell you if you really do have it enabled. 这将告诉您是否确实已启用它。 If not, read here . 如果没有,请在此处阅读。

It is not recommended for the faint-hearted Windows developer. 不建议那些胆小的Windows开发人员使用。

For windows OS users (It worked for me) in XAMPP. 对于XAMPP中的Windows操作系统用户(它对我有用)。

step 1: Go to C:\\xampp\\php\\php.ini 第1步:转到C:\\ xampp \\ php \\ php.ini

edit this file php.ini 编辑此文件php.ini

find curl- you will see a line ;extension=php_curl.dll. 找到curl-你会看到一行; extension = php_curl.dll。

remove semicolon (;)extension=php_curl.dll. 删除分号(;)extension = php_curl.dll。 so this line looks like 所以这条线看起来像

;extension=php_curl.dll

to

extension=php_curl.dll

step 2: copy ssleay32.dll, libeay32.dll from php folder. 第2步:从php文件夹中复制ssleay32.dll,libeay32.dll。 paste it in C:\\Windows\\System32\\ 将其粘贴到C:\\ Windows \\ System32 \\

step 3: Restart the system . 第3步:重新启动系统。 Curl will run successfully. Curl将成功运行。

check if curl module is available 检查卷曲模块是否可用

$ ls -la /etc/php5/mods-available/

enable the curl module 启用卷曲模块

$ sudo php5enmod curl

source: http://baligena.com/installing-curl-ubuntu-server/ 来源: http//baligena.com/installing-curl-ubuntu-server/

Check the php version, If you installed php 7.0 version 检查php版本,如果你安装了php 7.0版本

sudo apt-get install php7.0-curl
sudo service apache2 restart

If you installed php 5.6 version 如果你安装了php 5.6版本

sudo apt-get install php5-curl
sudo service apache2 restart

PHP 7^ version: PHP 7 ^版本:

sudo apt-get install php-curl
sudo service apache2 restart

如果以上都没有解决您的问题,并安装了php-x86(Windows 32位),那么问题可能是openssl - 更多信息: 如何修复libeay32.dll未找到错误

to install php5-curl under opensuse: 在opensuse下安装php5-curl

sudo yast2

->software ->software management ->search for curl ->check php5-curl case and accept. - >软件 - >软件管理 - >搜索curl - >检查php5-curl的情况并接受。

after installation you need to restart apache server 安装后需要重启apache服务器

service apache2 restart

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM