Skip to content

Instantly share code, notes, and snippets.

@rakibulinux
Last active August 10, 2023 06:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rakibulinux/645ab5aaef134bddc6103006d771e97b to your computer and use it in GitHub Desktop.
Save rakibulinux/645ab5aaef134bddc6103006d771e97b to your computer and use it in GitHub Desktop.
Installing OpenSSL on Ubuntu 18.04 LTS
#!/bin/sh
sudo apt-get update && sudo apt-get upgrade
openssl version -a
#Install the necessary packages for compiling
sudo apt install build-essential checkinstall zlib1g-dev -y
#Download OpenSSL
cd /usr/local/src/
sudo wget https://www.openssl.org/source/openssl-1.1.1c.tar.gz
sudo tar -xf openssl-1.1.1c.tar.gz
cd openssl-1.1.1c
#Install OpenSSL
sudo ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib
sudo make
sudo make test
sudo make install
#Configure OpenSSL Shared Libraries
cd /etc/ld.so.conf.d/
sudo nano openssl-1.1.1c.conf
/usr/local/ssl/lib
#Save and exit
sudo ldconfig -v
#Configure OpenSSL Binary
sudo mv /usr/bin/c_rehash /usr/bin/c_rehash.backup
sudo mv /usr/bin/openssl /usr/bin/openssl.backup
sudo nano /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/ssl/bin"
#Ensure to save before you exit
source /etc/environment
echo $PATH
#We can now check and verify our installation
which openssl
openssl version -a
#Use OpenSSl for Self-Signed SSL Certificate
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/my.key -out /etc/ssl/certs/my.crt
#Configure Nginx for SSL
server {
listen 443;
ssl on;
ssl_certificate /etc/ssl/your_domain_name.pem; (or bundle.crt)
ssl_certificate_key /etc/ssl/your_domain_name.key;
server_name your.domain.com;
access_log /var/log/nginx/nginx.vhost.access.log;
error_log /var/log/nginx/nginx.vhost.error.log;
location / {
root /home/www/public_html/your.domain.com/public/;
index index.html;
}
}
sudo /etc/init.d/nginx restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment