本文摘自php中文网,作者不言,侵删。
如何升级Mac中自带的openssl ?下面这篇文章就给大家介绍关于Mac中自带的openssl升级过程,有需要的可以参考一下。
由于Mac自带的 openssl
太老了,所以,这里因为安装python扩展包需要升级到高版本,所以,总结下升级过程。
一、安装openssl 首先,来看看我们的openssl 的版本和目录:
1
2
3
4
5
6
-> ~ openssl version
OpenSSL 0.9.8zh 14 Jan 2016
-> ~ which openssl
/usr/bin/openssl
-> ~
通过上面的查看,明显我们的版本号太低了。
按照上面的步骤,我们首先更新homebrew
安装:
1
2
3
4
brew install openssl
# 重新安装
# brew reinstall openssl
安装成功后:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
~ brew reinstall openssl
==> Reinstalling openssl
==> Downloading https:
Already downloaded: /Users/kaiyiwang/Library/Caches/Homebrew/downloads/96bc2acd84d0fe609dcbe4c6436c864808f7e8f26f2f12111f552f5972c3840a--openssl-1.0.2p.el_capitan.bottle.tar.gz
==> Pouring openssl-1.0.2p.el_capitan.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
/usr/local/etc/openssl/certs
and
run
/usr/local/opt/openssl/bin/c_rehash
openssl is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated
use
of OpenSSL in favor of its own TLS
and
crypto libraries.
If you need to have openssl first in your PATH run:
echo
'export PATH="/usr/local/opt/openssl/bin:$PATH"'
>> ~/.zshrc
For compilers to find openssl you may need to set:
export LDFLAGS=
"-L/usr/local/opt/openssl/lib"
export CPPFLAGS=
"-I/usr/local/opt/openssl/include"
==> Summary
/usr/local/Cellar/openssl/1.0.2p: 1,793 files, 12.2MB
说明我们成功的将openssl安装到/usr/local/Cellar/openssl/1.0.2p
。
二、更换旧的 不过,我们还有最后一步,那就是当我们使用openssl时,使用的是我们用homebrew新下载的openssl。为了达到这个目的,我们有两种方法。
将homebrew下载的openssl软链接
到/usr/bin/openssl
目录下。这里,我们先将它保存一份老的,然后再软链接新下载的。
1
2
3
4
$ mv /usr/bin/openssl /usr/bin/openssl_old
mv: rename /usr/bin/openssl to /usr/bin/openssl_old: Operation not permitted
$ ln -s /usr/local/Cellar/openssl/1.0.2p/bin/openssl /usr/bin/openssl
ln: /usr/bin/openssl: Operation not permitted
Operation not permitted提示没有权限操作,对/usr/bin目录下的东西,我已经遇到过几次这个问题了,于是继续google,在stackoverflow上找到了Operation Not Permitted when on root El capitan (rootless disabled)
。
重启系统,当启动的时候我们同时按下cmd+r进入Recovery模式,之后选择实用工具 => 终端,在终端输入如下命令,接口文件系统的锁定,并且重启电脑(cmd+r后,会进入另外一个选择系统启动的界面,在这个界面里面不要马上重新启动,先找到终端,在終端中输入csrutil disable):
1
2
$ csrutil disable
$ reboot
最后,我们执行前面两个命令,查看版本。
1
2
3
4
5
6
7
$ sudo mv /usr/bin/openssl /usr/bin/openssl_old
$ sudo ln -s /usr/local/Cellar/openssl/1.0.2p/bin/openssl /usr/bin/openssl
$ openssl version
OpenSSL 1.0.2p 14 Aug 2018
? ~ which openssl
/usr/local/opt/openssl/bin/openssl
这样,我们的openssl升级成功了。不过,为了安全起见,我还是重新启动电脑,然后重新开启了csrutil。
相关推荐:
macos - Mac如何给自带的PHP进行大版本升级?
以上就是如何升级Mac中自带的openssl ?(过程总结)的详细内容,更多文章请关注木庄网络博客 !!
相关阅读 >>
浅谈numpy数组的几种排序方式_Python
Python 中str和repr有什么区别
Python 按哪个键运行
实例介绍Python 随机数使用方法,推导以及字符串,双色球
Python 中list(列表)的使用方法总结(图文)
什么是Python 单元测试?(实例详解)
Python 中什么是算术运算符、赋值运算符和复合运算符?
centos 6.5下安装Python 3.5.2
Python 中一行和多行import模块问题_Python
Python 如何筛选序列中的元素
更多相关阅读请进入《Python 》频道 >>
¥69.8元 人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » 如何升级Mac中自带的openssl ?(过程总结)