0%

Unable to find the socket transport "ssl" – did you forget to enable it when you configured PHP?

今天在学习 laravel 框架时,通过命令行安装 bundle 时出现错误,经过三个小时的搜索调试,解决问题,记录如下。
报错截图:

出现这个的原因是 PHP 不支持 SSL,可能是编译的时候就不支持,也可能是在配置文件中没有加载 opensll 扩展。

解决方案:
Windows 下,
首先查找 php 的文件夹中的 ext 目录是否含有 php_openssl.dll,如果存在的话
找到加载的的 php.ini 查找 extension=php_openssl.dll,去除最前面的;号,重启服务。
如果不存在这个 dll,可参照 http://blog.yogo.tw/2009/08/phpopenssl.html
PS:

  1. 若改完 php.ini 重启 web server 却出現找不到”php_openssl.dll” 的错误,将”php_openssl.dll” 及在 C:php5 下 的 libeay32.dll、ssleay32.dll,3 个文件到”C:WINDOWSSystem32” 下,重启应该可以解决问题。

  2. 如果你安裝的 web server 是含 openssl 的 apache 的話,
    因为根据 windows 的设计,他会先查找 (如下英文字) apache/bin,所以 php 内置的就永远到不了了,请把 php_openssl.dll、libeay32.dll、ssleay32.dll 覆盖到 apache/bin 那才是程序执行的地方。

    When any application attempts to use a dll file in windows, the system searches for this file using the following order:

    1. The directory from which the application loaded.
    2. The windowssystem32 directory.
    3. The windowssystem directory.
    4. The windows directory.
    5. The current directory.
    6. The directories that are listed in the PATH environment variable.

Linux 下,重新编译 php,编译时加上参数–enable-ssl(具体参看 configure 的 help)。

开启后用 phpinfo () 查询如果出现下图就是成功加载了。

以上是解决了这篇博文标题描述的问题 针对大多数的情况应该可以解决,比如搭建 smtp 等等。

但是针对 laravel 命令行下无法安装 实际又是另一个问题。请参考 laravel 命令行下无法安装 bundle

坚持原创分享,您的支持将鼓励我继续创作!