原文: http://blog.csdn.net/zouqingfang/article/details/52513275
在PHP中使用RSA算法的时候,需要调用openssl_get_publickey方法,但同时需要对php编译openssl扩展,否则会提示以下错误:
由于php已经安装完毕,如何无需编译的情况下安装openss呢。这种方式操作步骤如下:
- 进入php源代码路径
- 使用phpize编译
此时会生成configure文件,这样就可以使用make命令安装
特别说明:需要设置php安装路径的环境变量.
- 执行make安装
特别说明:需要先安装openssl
- php.ini添加扩展配置openssl的扩展
- 验证是否增加成功
可以看到php的所有的扩展
Centos系统, 刚开始用lnmp装的PHP环境,本来是要安装composer的,但是在这行这个命令的时候
curl -sS https://getcomposer.org/installer | php
就报错了:
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:
The openssl extension is missing, which means that secure HTTPS transfers are impossible.
If possible you should enable it or recompile php with --with-openssl
不能忍啊,于是就给php安装openssl扩展,首先进入PHP源码包的ext/openssl目录下,执行以下命令,参见:http://www.52jscn.com/web/2013/05/4592.shtml
mv config0.m4 config.m4 /var/www/php5/bin/phpize ./configure --with-openssl --with-php-config=/path/to/php5/bin/php-config make make install
果断生成openssl.so,于是添加到php.ini中,执行service php-fpm restart,果断报错:openssl是未识别的PHP扩展。
接着折腾,参见:http://www.cnblogs.com/ycoe/archive/2012/02/15/2352604.html
在php源码目录上使用 ./configure --help查看配置所有可用参数,可以发现,找不到 --enable-ssl 取而代之的是: --with-openssl-dir --with-openssl 既然如此,就直接用它了 ./configure --with-openssl-dir=/usr/lib/openssl --with-openssl
目前仍在编译中~~~~