如何升级Mac中自带的openssl ?(过程总结)


本文摘自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

brew update

安装:

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://homebrew.bintray.com/bottles/openssl-1.0.2p.el_capitan.bottle.tar.gz

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

4075553207-5b914e6a57c15_articlex.png

这样,我们的openssl升级成功了。不过,为了安全起见,我还是重新启动电脑,然后重新开启了csrutil。

1

2

csrutil enable

reboot

相关推荐:

macos - Mac如何给自带的PHP进行大版本升级?

以上就是如何升级Mac中自带的openssl ?(过程总结)的详细内容,更多文章请关注木庄网络博客!!

相关阅读 >>

Python有64位的吗

Python需要编译么

Python 是什么?

Python函数(一)什么是函数

什么是Python items函数?怎么使用它?

Python爬虫怎么实现翻页

读懂Python的异常机制

format在Python中是什么意思

信息竞赛一定要Python

Python中str是什么

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...