简体   繁体   English

在Windows 8上使用PHP 5.6启用CURL

[英]Enabling CURL with PHP 5.6 on Windows 8

I have Apache 2.4.12 and php 5.6.9 on my Windows 8 computer and I'm trying to enable the curl extension for php however, I haven't had much success. 我的Windows 8计算机上有Apache 2.4.12和php 5.6.9,我正在尝试为php启用curl扩展,但是我没有取得多大成功。 After searching the internet for this issue it appears that other's have had the same trouble. 在互联网上搜索此问题之后,似乎其他人遇到了同样的问题。 Here are the suggestions I've found: 以下是我发现的建议:

  • Uncomment ;extension=php_curl.dll in php.ini 取消注释;extension=php_curl.dll php.ini中的;extension=php_curl.dll
  • Uncomment ;extension_dir = "ext" in php.ini 取消注释;extension_dir = "ext" php.ini中的;extension_dir = "ext"
  • Download and replace the php_curl.dll file in the ext directory of php with one from this website 下载并替换php的ext目录中的php_curl.dll文件与网站中的一个
  • Add to the PATH environment variable where php is installed 添加到安装php的PATH环境变量
  • Copy libeay32.dll and ssleay32.dll from where php is installed to C:\\Windows\\System32 将libeay32.dll和ssleay32.dll从安装php的地方复制到C:\\ Windows \\ System32

I've tried every single suggestion with no success except the third item in the list because it doesn't have a .dll file for curl with php 5.6, in fact the highest version avaible is one for php 5.4. 我已经尝试了除了列表中的第三项之外没有成功的每一个建议,因为它没有用于使用php 5.6的curl的.dll文件,实际上最高版本可用于php 5.4。 There has to be way to enable this extension without having to downgrade my php version to 5.4 and using a .dll file from that website. 必须有办法启用此扩展,而不必将我的PHP版本降级到5.4并使用该网站的.dll文件。 I've tried searching the internet for a .dll file like the one on the linked website for php 5.6 opposed to a version of php that's outdated but I've had no luck in finding one so I'd like help with this issue. 我已经尝试在互联网上搜索一个.dll文件,如链接网站上的那个文件,对于php 5.6,而且版本已经过时了,但是我没有找到一个好运,所以我想帮助解决这个问题。

How can I enable curl for php 5.6 on my Windows 8 machine? 如何在我的Windows 8机器上为php 5.6启用curl?

Locate your php folder and follow these instructions: 找到您的php文件夹并按照以下说明操作:

  1. Move to Windows\\system32 folder: 移至Windows \\ system32文件夹:

    libssh2.dll, php_curl.dll, ssleay32.dll, libeay32.dll libssh2.dll,php_curl.dll,ssleay32.dll,libeay32.dll

  2. Move to Apache24\\bin folder 移至Apache24 \\ bin文件夹

    libssh2.dll libssh2.dll

  3. Uncomment extension=php_curl.dll 取消注释extension = php_curl.dll

Note: Don't overwrite when prompted. 注意:提示时不要覆盖。

Source 资源

I give you an example of a set up that just worked perfectly for me : 我举一个适合我的设置示例:

  1. downloaded the VC11 x86 Thread Safe version of PHP , 下载了VC11 x86线程安全版的PHP
  2. unzipped it within a directory C:\\php , 在目录C:\\php压缩它,
  3. edited the php.ini-development , uncommenting 2 lines : 编辑了php.ini-development ,取消注释2行:
    • extension=php_curl.dll
    • extension_dir = "ext"
  4. saved this file under php.ini . php.ini下保存了这个文件。

I just tested it via the CLI (windows CMD here) on a PHP a file (ie C:\\php\\php myFile.php ) and cURL worked. 我刚刚在PHP文件(即C:\\php\\php myFile.php )上通过CLI(windows CMD)对它进行了测试,并且cURL正常工作。

If you have Apache installed and prefer to test it in a browser, you obviously have to adapt this installation with your own files structure and to do not forget to restart Apache. 如果你安装了Apache并且喜欢在浏览器中测试它,你显然必须使用自己的文件结构来调整此安装,并且不要忘记重新启动Apache。

Running apache service with a specific user other than local system solved the problem for me. 与本地系统以外的特定用户一起运行apache服务解决了我的问题。 You can test this easily by stopping the apache service and running manually <apache dir>\\bin\\httpd.exe . 您可以通过停止apache服务并手动运行<apache dir>\\bin\\httpd.exe轻松测试。

I fixed this problem by adding C:\\php and C:\\php\\ext to PATH system variables. 我通过将C:\\phpC:\\php\\extPATH系统变量来解决此问题。

  1. Press window + pause to bring up the System Properties page. 窗口 + 暂停以显示“系统属性”页面。
  2. Click Advanced System Settings 单击高级系统设置
  3. Click Environment Variables 单击“环境变量”

You'll see the Path variable in the System Variables box in the bottom. 您将在底部的System Variables框中看到Path变量。 Append your PHP path to that variable. 将PHP路径附加到该变量。 Now the system will be able to load the extensions. 现在系统将能够加载扩展。

In addition to uncommenting the line 除了取消注释线

;extension_dir = "ext"

Try also setting it to the absolute path of the PHP installation's ext folder and then restarting apache. 尝试将其设置为PHP安装的ext文件夹的绝对路径,然后重新启动apache。

eg: 例如:

extension_dir = "C:\PHP 5.6.19\ext"

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

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