IMO the best way to install openssl on MacOS is to use Homebrew. This will not only install openssl, but will also allow it to be upgraded in the future.
brew install openssl
If you want to make the Homebrew version the default (rather than the LibreSSL that comes with MacOS), you will also need put the Hombrew-installed openssl on your path ahead of the MacOS version. While it is possible to accomplish this by putting /opt/homebrew/bin on your PATH ahead of /usr/bin, I strongly discourage this, because it makes you vulnerable to unintentionally installing a malicious Homebrew package named something like ls that overrides your default ls with malicious code. Instead, my personal preference is to have a user-level directory where I maintain a small set of binaries that override the defaults.
# Create a user-level bin directory, if it doesn't already exist.
mkdir -p ~/bin
# Create a symlink to the Homebrew openssl, if such a symlink does not already exist
ln -fs /opt/homebrew/bin/openssl ~/bin/openssl
Then, put ~/bin on your PATH, ahead of /usr/bin. This part depends on which shell you are using. For bash, you can add this to your ~/.bash_profile.
# User-level binaries, manually added
PATH="${HOME}/bin:${PATH}"
Answer from Cameron Hudson on Stack ExchangeIMO the best way to install openssl on MacOS is to use Homebrew. This will not only install openssl, but will also allow it to be upgraded in the future.
brew install openssl
If you want to make the Homebrew version the default (rather than the LibreSSL that comes with MacOS), you will also need put the Hombrew-installed openssl on your path ahead of the MacOS version. While it is possible to accomplish this by putting /opt/homebrew/bin on your PATH ahead of /usr/bin, I strongly discourage this, because it makes you vulnerable to unintentionally installing a malicious Homebrew package named something like ls that overrides your default ls with malicious code. Instead, my personal preference is to have a user-level directory where I maintain a small set of binaries that override the defaults.
# Create a user-level bin directory, if it doesn't already exist.
mkdir -p ~/bin
# Create a symlink to the Homebrew openssl, if such a symlink does not already exist
ln -fs /opt/homebrew/bin/openssl ~/bin/openssl
Then, put ~/bin on your PATH, ahead of /usr/bin. This part depends on which shell you are using. For bash, you can add this to your ~/.bash_profile.
# User-level binaries, manually added
PATH="${HOME}/bin:${PATH}"
The first option is the simplest one: do nothing. macOS has shipped with OpenSSL preinstalled since 2000.
You can download a binary distribution of OpenSSL. The OpenSSL project does not itself publish binary releases, but they maintain a list of third-party resources that publish OpenSSL binaries.
You can install it using MacPorts.
You can install it using Homebrew.
You can compile it yourself. You already downloaded the source code, so all you need is to follow the instructions in the INSTALL.md file you are showing in your screenshot. I assume that, since you chose to use an inofficial development version, you may run into some bugs.
macos - How to install latest version of openssl Mac OS X El Capitan - Stack Overflow
macos - install openssl-devel on Mac - Stack Overflow
Struggling to install ruby and rails because of OpenSSL?
Stuck on RVM Ruby Installation with OpenSSL Issues on EC2 - Need Help!
Videos
Execute following commands:
brew update
brew install openssl
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
You will have the latest version of openssl installed and accessible from cli (command line/terminal). Since the third command will add export path to .bash_profile, the newly installed version of openssl will be accessible across system restarts.
Only
export PATH=$(brew --prefix openssl)/bin:$PATH in ~/.bash_profile
has worked for me! Thank you mipadi.
This has changed with the latest verison of brew on Big Sur (11.5.1) on a Macbook M1 (just for completeness):
export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
this command solve my problem:
brew install [email protected]
cp /usr/local/opt/[email protected]/lib/pkgconfig/*.pc /usr/local/lib/pkgconfig/