如何在 Windows 上安装和使用 curl?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9507353/
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
How do I install and use curl on Windows?
提问by pri_dev
I am having trouble getting curl to run on Windows.
我无法让 curl 在 Windows 上运行。
I have downloaded a curl zip file from here, but it seems to contain source code, not an executable.
我从这里下载了一个 curl zip 文件,但它似乎包含源代码,而不是可执行文件。
Do I needto compile curl to run it? If yes, then how do I do that?
我是否需要编译 curl 才能运行它?如果是,那么我该怎么做?
Where can I find .exe
downloads for curl?
我在哪里可以找到.exe
curl 的下载?
I have looked for documentation on installing curl, but there is little to be found.
我已经查找了有关安装 curl 的文档,但几乎找不到。
采纳答案by theglauber
Assuming you got it from https://curl.haxx.se/download.html, just unzip it wherever you want. No need to install. If you are going to use SSL, you need to download the OpenSSL DLLs, available from curl's website.
假设您是从https://curl.haxx.se/download.html 获取的,只需将其解压缩到您想要的任何位置。无需安装。如果您打算使用 SSL,您需要从 curl 的网站下载 OpenSSL DLL。
回答by Michiel van Oosterhout
You might already have curl
你可能已经有了 curl
It is possible that you won't need to download anything:
您可能不需要下载任何东西:
- If you are on Windows 10, version 1803 or later, your OS ships with a copy of curl, already set up and ready to use.
If you have Git for Windowsinstalled (if you downloaded Git from git-scm.com, the answer is yes), you have
curl.exe
under:C:\Program Files\Git\mingw64\bin\
Simply add the above path to
PATH
.
- 如果您使用的是 Windows 10 版本 1803 或更高版本,则您的操作系统附带了 curl 的副本,该副本已经设置并可以使用。
如果您安装了适用于 Windows 的 Git(如果您从git-scm.com下载了 Git ,答案是肯定的),您将拥有
curl.exe
:C:\Program Files\Git\mingw64\bin\
只需将上述路径添加到
PATH
.
Installing curl with a package manager
使用包管理器安装 curl
If you are already using a package manager, it may be more convenient to install with one:
如果您已经在使用包管理器,安装一个可能更方便:
- For Chocolatey, run
choco install curl
- For MSYS2, run
pacman -S curl
- For Scoop, run
scoop install curl
- For Cygwin, add the curl package in Cygwin Setup.
- 对于Chocolatey,运行
choco install curl
- 对于MSYS2,运行
pacman -S curl
- 对于Scoop,运行
scoop install curl
- 对于Cygwin,在 Cygwin Setup 中添加 curl 包。
Installing curl manually
手动安装 curl
Downloading curl
下载 curl
It is too easy to accidentally download the wrong thing. If, on the curl homepage, you click the large and prominent "Download" section in the site header, and then the large and prominent curl-7.62.0.tar.gz
link in its body, you will have downloaded a curl source package, which contains curl's source code but not curl.exe
. Watch out for that.
不小心下载错误的东西太容易了。如果在curl 主页上单击站点标题中大而显眼的“下载”部分,然后单击curl-7.62.0.tar.gz
其正文中大而显眼的链接,您将下载一个 curl源包,其中包含 curl 的源代码,但不包含curl.exe
. 请注意这一点。
Instead, click the large and prominent download links on this page. Those are the official Windows builds, and they are provided by the curl-for-winproject.
相反,请单击此页面上的大而显眼的下载链接。这些是官方的 Windows 版本,它们由curl-for-win项目提供。
If you have more esoteric needs (e.g. you want cygwin builds, third-party builds, libcurl, header files, sources, etc.), use the curl download wizard. After answering five questions, you will be presented with a list of download links.
如果您有更深奥的需求(例如,您想要 cygwin 构建、第三方构建、libcurl、头文件、源代码等),请使用 curl下载向导。回答五个问题后,您将看到一个下载链接列表。
Extracting and setting up curl
提取和设置 curl
Find curl.exe
within your downloaded package; it's probably under bin\
.
curl.exe
在您下载的软件包中查找;它可能在bin\
.
Pick a location on your hard drive that will serve as a permanent home for curl:
在硬盘驱动器上选择一个位置作为 curl 的永久位置:
- If you want to give curl its own folder,
C:\Program Files\curl\
orC:\curl\
will do. - If you have many loose executables, and you do not want to add many individual folders to
PATH
, use a single folder such asC:\Program Files\tools\
orC:\tools\
for the purpose.
- 如果你想给 curl 自己的文件夹,
C:\Program Files\curl\
还是C:\curl\
可以的。 - 如果您有许多松散的可执行文件,并且您不想将许多单独的文件夹添加到
PATH
,请使用单个文件夹,例如C:\Program Files\tools\
或C:\tools\
。
Place curl.exe
under the folder. And never move the folder or its contents.
将curl.exe
文件夹下。永远不要移动文件夹或其内容。
Next, you'll want to make curl available anywhere from the command line. To do this, add the folder to PATH
, like this:
接下来,您需要在命令行的任何地方使 curl 可用。为此,请将文件夹添加到PATH
,如下所示:
- Click the Windows 10 start menu. Start typing "environment".
- You'll see the search result Edit the system environment variables. Choose it.
- A System Properties window will popup. Click the Environment Variablesbutton at the bottom.
- Select the "Path" variable under "System variables" (the lower box). Click the Editbutton.
- Click the Addbutton and paste in the folder path where
curl.exe
lives. - Click OKas needed. Close open console windows and reopen, so they get the new
PATH
.
- 单击 Windows 10 开始菜单。开始输入“环境”。
- 您将看到搜索结果Edit the system environment variables。选择它。
- 将弹出系统属性窗口。单击底部的环境变量按钮。
- 选择“系统变量”下的“路径”变量(下方的框)。单击编辑按钮。
- 单击添加按钮并粘贴到所在的文件夹路径中
curl.exe
。 - 根据需要单击确定。关闭打开的控制台窗口并重新打开,以便他们获得新的
PATH
.
Now enjoy typing curl at any command prompt. Party time!
现在享受在任何命令提示符下键入 curl 的乐趣。派对时间!
回答by Ithar
- Download curl zip
- Extract the contents (if you have downloaded the correct version you should find curl.exe)
- Place curl.exe in a folder where you keep your software (e.g. D:\software\curl\curl.exe)
To run curl from the command line
a) Right-hand-click on "My Computer" icon
b) Select Properties
c) Click 'Advanced system settings' link
d) Go to tab [Advanced] - 'Environment Variables' button
e) Under System variableselect 'Path' and Edit button
f) Add a semicolon followed by the path to where you placed your curl.exe (e.g. ;D:\software\curl)
- 下载卷曲zip
- 提取内容(如果您下载了正确的版本,您应该找到 curl.exe)
- 将 curl.exe 放在您保存软件的文件夹中(例如 D:\software\curl\curl.exe)
从命令行运行 curl
a) 右键单击“我的电脑”图标
b) 选择属性
c) 单击“高级系统设置”链接
d) 转到选项卡 [高级] - '环境变量' 按钮
e) 在系统变量下选择“路径”和“编辑”按钮
f) 添加一个分号,后跟放置 curl.exe 的路径(例如 ;D:\software\curl)
Now you can run from the command line by typing:
现在您可以通过键入以下命令从命令行运行:
curl www.google.com
回答by Abel Callejo
The simplest tutorial for setting up cURLon Windowsis the Making cURL work on Windows 7. It only have 3 easy steps.
在Windows上设置cURL的最简单教程是使 cURL 在 Windows 7 上工作。它只有3 个简单的步骤。
回答by Benny Neugebauer
- Download cURL(Win64 ia64 zip binary with SSL)
- Extract curl.exeinto "
C:\Windows\System32
" - Done
- 下载 cURL(带有 SSL 的 Win64 ia64 zip 二进制文件)
- 将curl.exe解压到“
C:\Windows\System32
” - 完毕
Even more easier:
更简单:
Download the Win64 2000/XP x86_64 MSI installerprovided by Edward LoPinto.
下载Edward LoPinto 提供的Win64 2000/XP x86_64 MSI 安装程序。
At the time of writing file curl-7.46.0-win64.exe
was the most recent. Tested with Windows 10.
在编写文件时curl-7.46.0-win64.exe
是最新的。在 Windows 10 上测试。
回答by VonC
Starting with Windows 10 version 1803 (and earlier, with insider build 17063), you don't install curl
anymore. Windows includes a nativecurl.exe
(and tar.exe
) in C:\Windows\System32\
, which you can access right from your regular CMD
.
从 Windows 10 版本 1803(以及更早版本的内部版本 17063)开始,您不再安装curl
。Windows 在 中包含本机curl.exe
(和tar.exe
)C:\Windows\System32\
,您可以直接从常规CMD
.
C:\Users\vonc>C:\Windows\System32\curl.exe --version
curl 7.55.1 (Windows) libcurl/7.55.1 WinSSL
Release-Date: [unreleased]
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL
C:\Users\vonc>C:\Windows\System32\tar.exe --version
bsdtar 3.3.2 - libarchive 3.3.2 zlib/1.2.5.f-ipp
回答by user2233949
It's probably worth noting that Powershell v3 and up, contains a cmdlet called Invoke-WebRequestthat has some curl-ish capabilities. The New-WebServiceProxyand Invoke-RestMethodcmdlets are probably worth mentioning too.
可能值得注意的是,Powershell v3 及更高版本包含一个名为Invoke-WebRequest的 cmdlet ,它具有一些 curl-ish 功能。在新WebServiceProxy和调用,RestMethod的cmdlet可能是值得一提了。
I'm not sure they will fit your needs or not, but although I'm not a Windows guy, I have to say I find the object approach PS takes, a lot easier to work with than utilities such as curl, wget etc. They may be worth taking a look at
我不确定它们是否适合您的需求,但尽管我不是 Windows 人,但我不得不说我发现 PS 采用的对象方法,比 curl、wget 等实用程序更容易使用。他们可能值得一看
回答by RBV
Note also that installing Git for Windows from git-scm.comalso installs Curl. You can then run Curl from Git for Windows' BASH terminal (not the default Windows CMD terminal).
另请注意,从git-scm.com为 Windows 安装 Git也会安装 Curl。然后,您可以从 Git 为 Windows 的 BASH 终端(不是默认的 Windows CMD 终端)运行 Curl。
回答by ConfusedByCode
As you already know, you can find several packages of binaries on the official curl website.
如您所知,您可以在官方 curl 网站上找到多个二进制文件包。
Once you download a package, unzip it wherever you want. I recommend adding its location to your path, so you can call curl from batch or powershell scripts. To add a directory to your path type "environment variables" in the start menu, and select "edit user environment variables". Select Path, and add to the end of the "value" box: ;C:\curl\directory (with the directory changed to where you saved curl.)
下载软件包后,将其解压缩到您想要的任何位置。我建议将其位置添加到您的路径中,以便您可以从批处理或 powershell 脚本中调用 curl。要将目录添加到您的路径中,请在开始菜单中输入“环境变量”,然后选择“编辑用户环境变量”。选择路径,并在“值”框的末尾添加:;C:\curl\directory(将目录更改为您保存 curl 的位置。)
If you want to use SSL you need a certificate bundle. Run either mk-ca-bundle.pl (perl) or mk-ca-bundle.vbs (VBScript). Some of the packages of binaries include one or both of them. If your download doesn't include one, download one here: https://github.com/bagder/curl/tree/master/lib. I recommend mk-ca-bundle.vbs, as on windows you simply double click it to run it. It will produce a file called ca-bundle.crt. Rename it curl-ca-bundle.crt and save it in the directory with curl.exe.
如果您想使用 SSL,您需要一个证书包。运行 mk-ca-bundle.pl (perl) 或 mk-ca-bundle.vbs (VBScript)。一些二进制文件包包括其中之一或两者。如果您的下载不包含一个,请在此处下载一个:https: //github.com/bagder/curl/tree/master/lib。我推荐 mk-ca-bundle.vbs,因为在 Windows 上你只需双击它就可以运行它。它将生成一个名为 ca-bundle.crt 的文件。将其重命名为 curl-ca-bundle.crt 并保存在 curl.exe 所在的目录中。
Alternatively, I recently developed an msi installer that sets up a full featured build of curl with just a few clicks. It automatically ads curl to your path, includes a ready-to-use ssl certificate bundle, and makes the curl manual and documentation accessible from the start menu. You can download it at www.confusedbycode.com/curl/.
或者,我最近开发了一个 msi 安装程序,只需单击几下即可设置完整功能的 curl 版本。它会自动将 curl 广告添加到您的路径中,包括一个随时可用的 ssl 证书包,并使 curl 手册和文档可以从开始菜单访问。您可以在www.confusedbycode.com/curl/下载它。
回答by Adam
Install Chocolateypackage manager for Windows. Once installed, simply enter choco install curl
. Then you can use curl
from a terminal.
安装适用于 Windows 的Chocolatey包管理器。安装后,只需输入choco install curl
. 然后您可以curl
从终端使用。