Skip to main content

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.

  1. Edit the bash profile:
    bash
  2. nano ~/.bash_profile
    
  3. Add the following lines at the end of the file (adjusting username if necessary):
    bash
  4. 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"
    
  5. Save and close the file, then reload your profile:
    bash
source ~/.bash_profile

Method 3: Verify the installation

  1. Check the version to ensure you are using the new installation:
    bash
  2. openssl version
    
    This should output the version you installed (e.g., OpenSSL 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