LNMPA 升级OpenSSL

1、OpenSSL源码升级

到https://www.openssl.org/source/ 找想要的版本,拿到链接wget下来:

wget https://www.openssl.org/source/openssl-1.0.1u.tar.gz
tar -zxvf openssl-1.0.1u.tar.gz
cd openssl-1.0.1u.tar.gz
./config shared zlib //一定记得加上shared选项,不然会导致OpenSSL Library Version 和OpenSSL Header Version不一致
make && make install
#备份以前的OpenSSL文件
mv /usr/bin/openssl /usr/bin/openssl.old
mv /usr/include/openssl /usr/include/openssl.old
#设置软链接
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl 
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
#更新链接
echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
ldconfig -v

  如果成功执行

openssl version

  会返回刚才安装的版本。

2、重新编译PHP

#查看编译时的参数
/usr/local/php/bin/php -i | grep Command

  会返回格式如:

./configure'  '--prefix=/usr/local/php' '--with-mysql' '--with-mysqli' '--with-iconv-dir' '--with-zlib' '--with-libxml-dir' '--enable-xml' '--with-curl' '--enable-fpm' '--enable-mbstring' '--with-gd' '--with-openssl' '--with-mhash' '--enable-sockets' '--with-xmlrpc' '--enable-zip' '--enable-soap' '--disable-fileinfo'

  把单引号去掉,—with-openssl改成—with-openssl=/usr/local/ssl/,重新编译之前要重装libiconv,

不然会报undefined reference to `libiconv_open。操作如下命令:

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar -zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/libiconv
make && make install

  然后将—with-iconv-dir修改为—with-iconv=/usr/local/libiconv。

然后进入安装的PHP版本的源码包,重新编译,进入PHP相应版本包内,make && make install。
如果是LNMP环境到此就结束了。
3、重新编译Apache
先到安装Apacher的目录下的build/config.nice文件中查看编译安装Apache时的参数,文件内容类似如下:

#! /bin/sh
#
# Created by configure
"./configure" 
"--prefix=/usr/local/apache" 
"--enable-mods-shared=most" 
"--enable-headers" 
"--enable-mime-magic" 
"--enable-proxy" 
"--enable-so" 
"--enable-rewrite" 
"--with-ssl" 
"--enable-ssl" 
"--enable-deflate" 
"--enable-suexec" 
"--with-included-apr" 
"--with-mpm=prefork" 
"--with-expat=builtin" 
"$@"

  将双引号、反斜杠去掉,并且在—with-ssl后面换上新OpenSSL的路径,这里安装在/usr/local/ssl/下,就改成—with-ssl=/usr/local/ssl。然后进入Apache对应版本的源码包中重新编译,安装。

成功后phpinfo即可看到新安装的OpenSSL版本。

原文地址:https://www.cnblogs.com/ouruola863/p/8939786.html