install OpenSSL locally on Ubuntu
To install OpenSSL locally on Ubuntu, you can
compile and install it from source by first installing build tools, then downloading and extracting the OpenSSL source code, and finally running the config, make, and make install commands with the appropriate prefix and flags. For the simplest local installation, download the source, change to the directory, and use ./config --prefix=/openssl --openssldir=/openssl, followed by make and make install, then update your ~/.bash_profile with the correct PATH and LD_LIBRARY_PATH.
Method 1: Install from source to a local directory
This method installs a specific version of OpenSSL to a custom directory, like
~/openssl, so it doesn't interfere with the system-installed version.bash
# Install build tools
sudo apt update
sudo apt install build-essential zlib1g-dev
# Create a working directory and download OpenSSL source
cd /usr/local/src/
wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
tar -xf openssl-1.1.1k.tar.gz
cd openssl-1.1.1k
# Configure and build (using --prefix to specify local install)
./config --prefix=~/openssl --openssldir=~/openssl
make
# Install to the local directory
make install
Method 2: Update your environment variables
After installing from source, you must tell your shell where to find the new binaries and libraries.
- Edit the bash profile:
bash
-
nano ~/.bash_profile - Add the following lines at the end of the file (adjusting
usernameif necessary):bash -
export PATH=$HOME/openssl/bin:$PATH export LD_LIBRARY_PATH=$HOME/openssl/lib:$LD_LIBRARY_PATH export LDFLAGS="-L $HOME/openssl/lib -Wl,-rpath,$HOME/openssl/lib" - Save and close the file, then reload your profile:
bash
source ~/.bash_profile
Method 3: Verify the installation
- Check the version to ensure you are using the new installation:
bash
-
This should output the version you installed (e.g.,openssl versionOpenSSL 1.1.1k 25 Mar 2025).
Verify the path to confirm it's the local one:bash
which openssl
This should point to ~/openssl/bin/openssl