为PHP增加OpenSSL扩展
目录
程序需要 OpenSSL 支持时,常见错误:
unable to connect to ssl://gateway.sandbox.push.apple.com:2195
(Unable to find the socket transport ssl - did you forget to enable it when you configured PHP?
检查是否已安装
查看 php 已编译的所有模块:
php -m | grep openssl
或通过 phpinfo() 函数查看。
安装步骤
- 确定 PHP 版本
php -v
- 下载对应版本源码
wget http://museum.php.net/php5/php-5.3.6.tar.gz
tar zxvf php-5.3.6.tar.gz
- 编译 openssl 扩展
cd php-5.3.6/ext/openssl/
cp config0.m4 config.m4
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-openssl
make
make install
- 在 php.ini 中添加扩展
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"
extension = "openssl.so"
- 重启 Apache
/usr/local/apache/bin/apachectl -k restart