php教程

安装

要 PHP 支持 cURL,必须在编译 PHP 时加上 --with-curl[=DIR] 选项,DIR 为包含 libinclude 的目录路径。在 include 目录中必须有一个名为curl,包含了easy.hcurl.h 的文件夹。lib文件夹里应该有一个名为libcurl.a的文件。对于 PHP 4.3.0 你可以配置 --with-curlwrappers 使 cURL 使用 URL 流。

Note: Win32 用户注意
要在 Windows 环境下使用这个模块,libeay32.dllssleay32.dll 必须放到 PATH 环境变量包含的目录下。 不用 cURL 网站上的libcurl.dll

User Contributed Notes

Tovster 23-Jun-2019 10:06
I had curl not working in Windows with Apache 2.4 and PHP 7.3 - Strangly phpinfo showed author but not curl section/panel.

I changed the widows path to include the PHP directory and after a reboot it started working.

You can change the windows path in Control Panel -> System -> Advanced System Settings -> Advanced -> Environment Variables  then edit the path variable in "System Variables"
pidog 19-Dec-2018 06:35
Installing on Ubuntu I had to do an extra step

$ sudo apt-get install php7-curl
$ sudo phpenmod curl
$ sudo service apache2 restart
Anonymous 08-Mar-2018 10:46
Hi.
This is test email from Jay Cutler.
i am a body builder.
1004707812 at qq dot com 08-Feb-2018 06:32
Win10 64bit, php7 x64,apache x64
It's important to set " extension_dir = "X:/WAMP/php/ext" " clearly in php.ini .
Remember some names of dll has changed recently, specially in the  x64 environment.
anonymous 26-Jan-2018 10:38
Upgrading to php 7.1.6 on Apache 2.4 32bit version Windows 7 x64

this curl  implementation works:

1.   C:/(path to php folder)/php.ini
enable extension=php_curl.dll

libeay32.dll, ssleay32.dll, libssh2.dll find directly in php7 folder

2. add this to Apache/conf/httpd.conf
# load curl and open ssl libraries
LoadFile "C:/(path to php folder)/libeay32.dll"
LoadFile "C:/(path to php folder)/ssleay32.dll"
LoadFile "C:/(path to php folder)/libssh2.dll"
epos_jk 27-Nov-2017 04:22
You dont need to copy files to use PHP CURL with Apache 2.4 - use the LoadFile directive in your apache config file instead:
LoadFile "C:/php7/libssh2.dll"
(that was all it took for me to get it work)
epos_jk 27-Nov-2017 04:21
Beginning with version 1.1.0 OpenSSL did change their libary names!
libeay32.dll is now libcrypto-*.dll (e.g. libcrypto-1_1-x64.dll for OpenSSL 1.1.x on 64bit windows)
ssleay32.dll is now libssl-*.dll (e.g. libssl-1_1-x64.dll for OpenSSL 1.1.x on 64bit windows)
gerald at drouillard dot biz 03-Feb-2017 06:30
For Ubuntu and probably debian:
apt install php-curl
karliskavacis at gmail dot com 22-Feb-2016 08:07
In my case, while running Windows 10 and Apache Httpd 2.4, I had to add my PHP7 root directory to Windows PATH and it resolved issues with failing to load couple of PHP extensions.
mesamorpho 02-Oct-2015 01:57
At least for windows builds of PHP, module dependencies (such as "libeay32.dll",  "libssh2.dll", "ssleay32.dll", etc. for php_curl) are mentioned in "snapshot.txt" included in the base folder of each PHP install.

For WampServer (I'm on an old version of 2.0 but this still applies at least up to version 2.5),  ensure that all dependencies are listed in an array assigned to "$phpDllToCopy" in "Wamp\scripts\config.inc.php". This ensures that when you switch the version of PHP in WAMP, WAMP copies the dependencies from the base folder of the selected PHP install (e.g., "Wamp\bin\php\php5.4.42") to the "bin" folder of the currently selected version of Apache (e.g., "Wamp\bin\apache\apache2.2.13\bin").

This also keeps you from either manually doing the same (whereby it should be noted that the versions of the dependencies often differ between versions of PHP, so you may have to do this each time you switch the current version of PHP), copying the appropriate dependencies to the Windows "System32" or "SysWOW64" subfolders, or manually adding the path to the currently used version of PHP to your PATH environment variable.
lymer at ca dot ibm dot com 29-Jul-2015 07:09
For Windows 7 (64 bit), ensure you not only enable the curl extension (i.e. uncomment "extension=php_curl.dll" in php.ini) as described in this manual, but also set the extension directory for Windows (e.g. extension_dir = "ext") in the php.ini file.  Adding / copying dll files or changing the system path were not necessary.  (Versions used: Apache 2.4.1 (Win64) and PHP 5.5.15.)
Developtus.com 29-May-2015 03:38
Upgrading to php 5.6.9 on Windows 7 x64 curl no longer is recognised. No errors on server start package just not available and didn't show in phpinfo.php. deplister.exe was ok
I fixed coping the following list files from php folder (in my case D:\xampp\php)
libeay32.dll
libssh2.dll
ssleay32.dll
to c:\xampp\apache\bin (or your apache\bin path), restart apache and works fine, apache's libraries were outdated
jwagner at digilog dot de 14-Oct-2014 07:07
On Windows hosts libeay32.dll and ssleay32.dll have to be path-accessible for php_curl.dll to work correctly. Copying them into System32 (or even into the Windows main directory) is a bad hack (and does not even work with newer PHP versions). The right way to do it, is to add the PHP path to the Windows *Path* variable. In *Control Panel* --> *System* click on *Advanced System Settings* and use the button *Environment Variables*. Under *System Variables* you will find the *Path* variable. Edit it and append `;C:/PHP` to it - or whatever the path to your PHP root folder is.
jorijnsmit at gmail dot com 22-Mar-2014 06:44
It is not necessary to always (re)compile PHP. For me it was sufficient to install php5-curl and restart Apache:

$ sudo apt-get install php5-curl
$ sudo /etc/init.d/apache2 restart
aaron at iodragon dot com 07-Feb-2014 07:56
make sure there is a curl-config under DIR or DIR/bin
otherwise there will be an error when running ./configure
TristanV 13-Dec-2013 11:41
If you are running on Windows with a Wampserver or alike preconfigured PHP, if you did everything that was advised (path is correct, dlls are in the System32 or the Wow64 folder, php_curl extension uncommented in the php.ini, rebooted your machine and restarted your services), and you still receive messages saying that curl is not installed :
- maybe you are running a command line script (and not a curl instruction within a web application). If yes, remember that there are 2 distinct php.ini configuration files : one for the php-cli commands (run php at command line) and one for the php instructions (run from a page in your www folder).
Wampserver's menuitem "php.ini" only opens the webserver's php.ini, not the php-cli one.
So it will be great to check your php-cli's php.ini configuration file ! (you'll find it in the php.exe's installation folder)
You need to uncomment the extension php_curl in this php.ini file for the command lines to work with curl.
Also uncomment the php_openssl extention by the way (often used with curl).
I hope this fixed issue will help someone else :)
musicdev at gmail dot com 15-May-2013 12:46
A tip for users that now use the latest version of Windows 7 Ultimate, Apache 2.2.22 and PHP 5.4.4.  If you manually installed PHP and did not change the PHP folder name such as "C:\php-5.4.4-Win32-VC9-x86" you don't need to add the curl libs into the System32 directory.  Instead, modify the php.ini cURL extension to point directly to the php_curl.dll as follows:

extension=C:\php-5.4.4-Win32-VC9-x86\ext\php_curl.dll

I added the libs to system32 and moded the path as well just in case.  Worked well for me.
jmichieli76 at yahoo dot ca 18-Jun-2012 02:03
It should be noted that on a standard installation of php 5.2.17 on windows has this functionality installed and enabled by default.
y dot gonzalez at bifie dot at 13-Oct-2011 05:06
For users of win7 64:
I just copied the library php_curl.dll to System32 and it works like charm ;-)
Joseph Marlin 13-Jun-2011 10:57
Ubuntu 11.04

I already had Apache and PHP5 setup, but simply adding php5-curl and curl did *not* work. I also had to get libcurl3 and libcurl3-dev. The full command:

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

You'll know if it works because phpinfo() will get a new section with Curl info.
Anonymous 04-Jan-2011 12:39
For Windows 64, put the DLLs into the Windows/SysWOW64 Folder.
Anonymous 30-Nov-2010 05:40
It's not sufficient to put libeay32.dll and ssleay32.dll into your path.  They also need to be in the PHP directory or it will not function, apparently.
wixelbomb at yahoo dot com 28-Dec-2009 11:17
Just an additional note for Windows XP installations ...

The instructions others have courteously given still lack one small item for those who have the Windows/system32 directory as the repository for the .dll files concerned with php_curl.

Go to the ext directory of your php installation and copy php_curl.dll  to the Windows/system32 folder after you have followed the advise given elsewhere.

So ...
1) remove ';' from extension=php_curl.dll in php.ini
2) ensure that  ssleay32.dll and libeay32.dll are in Windows/system32.
3) Copy php_curl.dll into Windows\System32 as well.

G'day

bearstate
regs at voidship dot net 23-Sep-2008 09:45
If you're dense like I am, spare yourself the trouble on an Ubuntu system (probably Debian too) and...

$ sudo apt-get install php5-curl

Then feel dumb, but not as dumb as me.
cristianods at yahoo dot com 14-Aug-2008 06:53
Tip for Installing cURL with AppServ development server on Windows

If you are running AppServ as a WAMP development environment on a Windows machine, you may experience difficulty installing cURL. Here are some helpful steps:

First go to the PHP directory and copy the following libraries to the windows/system32 dir.
ssleay32.dll
libeay32.dll

Open the php ini file and remove the ; from extension=php_curl.dll

Reboot your machine to load [...]
comments at adstation-systems dot com 09-Aug-2008 08:23
You may be confused, as I was, by the instructions for installing cURL in php.  The instruction "To use PHP's cURL support you must also compile PHP --with-curl[=DIR]..." was murky to me, since I didn't compile php when I installed it.  I just copied all of the necessary files to the correct folders as described very clearly in the php manual.

I am using Windows XP and Apache with php 5.1.6. In this situation, and it may apply to php versions of 5.0 and later, all one needs to do is remove the ";" from the front of the directive extension=php_curl.dll.  You should also check to make certain that libeay32.dll and ssleay32.dll are in your php directory with the other dll's.  This directory should already be in you path, so the instruction to put them in you path is not critical.

You can then run phpinfo() and you should see a heading for curl in the listing.

Succinctly, my installation of cURL consisted of removing the semi-colon in front of the ;extension=php_curl.dll line in php.ini, saving php.ini and restarting Apache.  You may wish to try this if you are using php 5.0 and later and are having difficulty understanding the instructions on the cURL installation page at php.net

You might also find the information at http://curl.phptrack.com/forum/viewtopic.php?t=52 useful.
rohanshenoy at w3hobbyist dot com 21-Jul-2008 09:21
If you are using WAMPserver, you can enable the cURL extensions by
Left-click on WAMPserver tray icon>PHP>PHP extensions> Check php_curl.

Its already loaded on your disk, you have to activate it.
Christopher McCulloh 18-Jul-2008 08:40
If you are using XAMPP (http://www.apachefriends.org/en/index.html) all you have to do is uncomment this line (line 582):

extension=php_curl.dll

in the xampp\apache\bin\php.ini file.

CopyRight © 2008-2022 verySource.Com All Rights reserved. 京ICP备17048824号-1 京公网安备:11010502034788