I've seen this error happen when php is compiled with a version of cURL that uses under Yosemite and the target of the URL request doesn't support SSLv3 (which was probably disabled due to the). What is the output of this command?
$ php -i | grep "SSL Version"
I suspect you'll see this:
SSL Version => SecureTransport
You can overcome this by installing a version of php which uses a version of cURL which uses OpenSSL instead of SecureTransport. This is most easily done with. So install that first if you don't already have it. If homebrew is installed but you haven't runbrew update
since upgrading to Yosemite, do that first. Also make sure you've installed XCode >= 6.1 and the latest XCode command line tools.brew doctor
will tell you if you've done it all right.
Add the Homebrew taps below that you will need in order to get brewed php installed. Skip this step if these repos are already tapped. If you're unsure if these repos are already tapped, just run the commands below. Worst case scenario, you'll get a harmlessWarning: Already tapped!
$ brew tap homebrew/dupes$ brew tap homebrew/versions$ brew tap homebrew/php
Then install curl with openssl:
$ brew install --with-openssl curl
Then install php using the curl you just installed and brewed openssl:
$ brew install \ --with-apache \ --with-homebrew-curl \ --with-homebrew-openssl \ --without-snmp php55
- if you're running nginx change
--with-apache
to--with-fpm
. - the
--without-snmp
is necessary because of . - if using apache, make sure to add
LoadModule php5_module /usr/local/opt/php55/libexec/apache2/libphp5.so
to your/etc/apache2/httpd.conf
and restart apache.
Install any php extensions you're going to need eg. mcrypt
.
$ brew install php55-mcrypt
After you're done, run this again:
$ php -i | grep "SSL Version"
And you should see:
SSL Version => OpenSSL/1.0.1j
And now, re-test your application and the SSLRead() return error -9806
should go away.
大概意思:
先使用命令
php -i |grep "SSL Version"
看看SSL Version的信息,猜想你看到是:
SSL Version => SecureTransport
那么,就可以按照下面的命令去做:
$ brew tap homebrew/dupes
$ brew tap homebrew/versions
$ brew tap homebrew/php
有可能会出现不伤大雅的警告信息:Already tapped!
重点来了:
然后使用openssl安装curl,这就是要替换掉原来的curl,命令如下:
$ brew install --with-openssl curl
然后使用刚才安装的curl和openssl安装php:
$ brew install \ --with-apache \ --with-homebrew-curl \ --with-homebrew-openssl \ --without-snmp php55
- 如果你想运行nginx,将
--with-apache
改为--with-fpm
. - 因为
--without-snmp是必须
. - 如果使用apache,确保添加
LoadModule php5_module /usr/local/opt/php55/libexec/apache2/libphp5.so到
/etc/apache2/httpd.conf
并重启apache.
安装你需要的php的其他扩展,例如 : mcrypt
.
$ brew install php55-mcrypt
完成后,再次运行下面的命令:
$ php -i | grep "SSL Version"
你会看到:
SSL Version => OpenSSL/1.0.1j
好吧,这个问题就这样解决了。