{"id":4836,"date":"2018-06-13T22:21:15","date_gmt":"2018-06-13T18:21:15","guid":{"rendered":"https:\/\/www.howtoforge.com\/tutorial\/how-to-install-openssl-from-source-on-linux\/"},"modified":"2018-06-13T22:21:15","modified_gmt":"2018-06-13T18:21:15","slug":"how-to-install-the-latest-openssl-version-from-source-on-linux","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/how-to-install-the-latest-openssl-version-from-source-on-linux\/","title":{"rendered":"How to Install the latest OpenSSL version from Source on Linux"},"content":{"rendered":"<p>OpenSSL is a widely used crypto library that implements SSL and TLS protocols\u00a0to secure communications over computer networks. OpenSSL is widely used by many software like Apache web server, PHP, Postfix and many others. OpenSSL offers support for different cryptographic algorithms such as Chipers (AES, Blowfish, DES, IDEA etc), Cryptographic hash functions (MD5, MD4, SHA-1, SHA-2 etc), and Public-key cryptography (RSA, DSA, Diffie-Hellman key exchange).<\/p>\n<p>In this tutorial, I will show you step-by-step how to install the latest stable OpenSSL version from source on the Ubuntu 18.04 and CentOS 7.5 servers.<\/p>\n<h2 id=\"what-we-will-do\">What we will do?<\/h2>\n<ol>\n<li>Install Dependencies<\/li>\n<li>Download OpenSSL Source Code<\/li>\n<li>Install OpenSSL<\/li>\n<ol>\n<li>Compile and Install OpenSSL<\/li>\n<li>Configure Link Libraries<\/li>\n<li>Configure OpenSSL Binary<\/li>\n<\/ol>\n<li>Testing<\/li>\n<\/ol>\n<h2 id=\"step-install-dependencies\">Step 1 &#8211; Install Dependencies<\/h2>\n<p>The first step we must do for compiling the OpenSSL manually from source is installing some package dependencies including the &#8216;build-essential&#8217; package on Ubuntu, or &#8216;Development Tools&#8217; package on CentOS.<\/p>\n<h3 id=\"on-ubuntu-\">On Ubuntu 18.04<\/h3>\n<p>Update the Ubuntu repository and install package dependencies for software compilation using the apt command below.<\/p>\n<p class=\"command\">sudo apt update<br \/>sudo apt install build-essential checkinstall zlib1g-dev -y<\/p>\n<h3 id=\"on-centos-\">On CentOS 7.5<\/h3>\n<p>Install the &#8216;Development Tools&#8217; and some packages libraries using the yum command.<\/p>\n<p class=\"command\">yum group install &#8216;Development Tools&#8217;<br \/>yum install perl-core zlib-devel -y<\/p>\n<p>After the installation is complete, go to the next step.<\/p>\n<h2 id=\"step-download-openssl\">Step 2 &#8211; Download OpenSSL<\/h2>\n<p>In this tutorial, we will install the latest stable version of OpenSSL &#8211; OpenSSL 1.0.2o. You can download the source code from the <a href=\"https:\/\/www.openssl.org\/source\/\" target=\"_blank\" rel=\"noopener\">OpenSSL site<\/a>.<\/p>\n<p>Go to the &#8216;\/usr\/local\/src&#8217; directory and download the OpenSSL source code using wget.<\/p>\n<p class=\"command\">cd \/usr\/local\/src\/<br \/>wget https:\/\/www.openssl.org\/source\/openssl-1.0.2o.tar.gz<\/p>\n<p>Now extract the openssl.tar.gz file, and go to the &#8216;openssl&#8217; directory.<\/p>\n<p class=\"command\">tar -xf openssl-1.0.2o.tar.gz<br \/>cd openssl-1.0.2o<\/p>\n<p><a class=\"fancybox\" id=\"img-11\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_openssl_from_source_on_linux\/big\/11.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-the-latest-openssl-version-from-source-on-linux.png\" alt=\"Download OpenSSL source\" width=\"500\" height=\"154\" title=\"\"><\/a><\/p>\n<p>The OpenSSL source code has been downloaded.<\/p>\n<h2 id=\"step-install-openssl\">Step 3 &#8211; Install OpenSSL<\/h2>\n<p>Before installing the custom OpenSSL version to the system, let&#8217;s check the installed version using the command below.<\/p>\n<p class=\"command\">openssl version -a<\/p>\n<p>Below is my results on Ubuntu 18.04.<\/p>\n<p><a class=\"fancybox\" id=\"img-2\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_openssl_from_source_on_linux\/big\/2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-the-latest-openssl-version-from-source-on-linux-1.png\" alt=\"Compile OpenSSL on Ubuntu 18.04\" width=\"500\" height=\"93\" title=\"\"><\/a><\/p>\n<p>And this is on CentOS 7.5.<\/p>\n<p><a class=\"fancybox\" id=\"img-3\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_openssl_from_source_on_linux\/big\/3.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-the-latest-openssl-version-from-source-on-linux-2.png\" alt=\"Compile OpenSSL on CentOS 7\" width=\"500\" height=\"107\" title=\"\"><\/a><\/p>\n<p>We will replace the &#8216;1.1.0g&#8217; version with the latest stable version 1.0.2o.<\/p>\n<p>We will install the new OpenSSL version to the specific directory &#8216;\/usr\/local\/ssl&#8217;, and then enable the Link Libraries of OpenSSL, and configure the new binary PATH for OpenSSL.<\/p>\n<h3 id=\"-install-and-compile-openssl\">&#8211; Install and Compile OpenSSL<\/h3>\n<p>Go to the openssl downloaded directory &#8216;\/usr\/local\/src\/openssl&#8217;.<\/p>\n<p class=\"command\">cd \/usr\/local\/src\/openssl-1.0.2o<\/p>\n<p>Configure and compile OpenSSL with commands below.<\/p>\n<p class=\"command\">.\/config &#8211;prefix=\/usr\/local\/ssl &#8211;openssldir=\/usr\/local\/ssl shared zlib<\/p>\n<p>make<br \/>make test<\/p>\n<p>Wait for the OpenSSL compile process.<\/p>\n<p><strong>Note:<\/strong><\/p>\n<ul>\n<li>&#8211;prefix and &#8211;openssldir = Set the output path of the OpenSSL.<\/li>\n<li>shared = force to create a shared library.<\/li>\n<li>zlib = enable the compression using zlib library.<\/li>\n<\/ul>\n<p>When the compile process is complete, install the OpenSSL using the command below.<\/p>\n<p class=\"command\">make install<\/p>\n<p><a class=\"fancybox\" id=\"img-4\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_openssl_from_source_on_linux\/big\/4.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-the-latest-openssl-version-from-source-on-linux-3.png\" alt=\"make install\" width=\"500\" height=\"201\" title=\"\"><\/a><\/p>\n<p>OpenSSL is installed in the &#8216;\/usr\/local\/ssl&#8217; directory.<\/p>\n<p><a class=\"fancybox\" id=\"img-5\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_openssl_from_source_on_linux\/big\/5.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-the-latest-openssl-version-from-source-on-linux-4.png\" alt=\"Check OpenSSL installation\" width=\"500\" height=\"224\" title=\"\"><\/a><\/p>\n<h3 id=\"-configure-link-libraries\">&#8211; Configure Link Libraries<\/h3>\n<p>Next, we will configure the shared libraries for OpenSSL. The new OpenSSL binary will load library files from the &#8216;\/usr\/local\/ssl\/lib&#8217; directory.<\/p>\n<p>Go to the &#8216;\/etc\/ld.so.conf.d&#8217; directory and create new configuration file &#8216;openssl-1.0.2o.conf&#8217;.<\/p>\n<p class=\"command\">cd \/etc\/ld.so.conf.d\/<br \/>vim openssl-1.0.2o.conf<\/p>\n<p>Paste the openssl library path directory.<\/p>\n<pre>\/usr\/local\/ssl\/lib<\/pre>\n<p>Save and exit.<\/p>\n<p>Now reload the dynamic link using the command below.<\/p>\n<p class=\"command\">sudo ldconfig -v<\/p>\n<p>And you will see the OpenSSL libraries on the &#8216;\/usr\/local\/ssl\/lib&#8217; directory has been loaded.<\/p>\n<p>Ubuntu 18.04.<\/p>\n<p><a class=\"fancybox\" id=\"img-6\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_openssl_from_source_on_linux\/big\/6.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-the-latest-openssl-version-from-source-on-linux-5.png\" alt=\"ldconfig on Ubuntu 18.04\" width=\"500\" height=\"206\" title=\"\"><\/a><\/p>\n<p>CentOS 7.5.<\/p>\n<p><a class=\"fancybox\" id=\"img-7\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_openssl_from_source_on_linux\/big\/7.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-the-latest-openssl-version-from-source-on-linux-6.png\" alt=\"ldconfig on CentOS 7\" width=\"500\" height=\"449\" title=\"\"><\/a><\/p>\n<h3 id=\"-configure-openssl-binary\">&#8211; Configure OpenSSL Binary<\/h3>\n<p>We will replace the default openssl binary &#8216;\/usr\/bin\/openssl or \/bin\/openssl&#8217; with the new version &#8216;\/usr\/local\/ssl\/bin\/openssl&#8217;.<\/p>\n<p><strong>On Ubuntu 18.04<\/strong><\/p>\n<p>Backup the binary files.<\/p>\n<p class=\"command\">mv \/usr\/bin\/c_rehash \/usr\/bin\/c_rehash.BEKUP<br \/>mv \/usr\/bin\/openssl \/usr\/bin\/openssl.BEKUP<\/p>\n<p>Edit the &#8216;\/etc\/environment&#8217; file using <a href=\"https:\/\/www.howtoforge.com\/vim-basics\" target=\"_blank\" rel=\"noopener\">vim<\/a>.<\/p>\n<p class=\"command\">vim \/etc\/environment<\/p>\n<p>Now add the new OpenSSL binary directory as below<\/p>\n<pre>PATH=\"\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin:\/usr\/games:\/usr\/local\/games:\/usr\/local\/ssl\/bin\"<\/pre>\n<p>Save and exit.<\/p>\n<p>Reload the environment file and test new updated binary PATH.<\/p>\n<p class=\"command\">source \/etc\/environment<br \/>echo $PATH<\/p>\n<p>Now check again the OpenSSL binary file.<\/p>\n<p class=\"command\">which openssl<\/p>\n<p>You will get the result as below.<\/p>\n<p><a class=\"fancybox\" id=\"img-8\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_openssl_from_source_on_linux\/big\/8.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-the-latest-openssl-version-from-source-on-linux-7.png\" alt=\"Configure OpenSSL Binary on Ubuntu\" width=\"500\" height=\"214\" title=\"\"><\/a><\/p>\n<p>The binary path openssl for Ubuntu has been updated.<\/p>\n<p><strong>On CentOS 7.5<\/strong><\/p>\n<p>Backup centos OpenSSL binary files.<\/p>\n<p class=\"command\">mv \/bin\/openssl \/bin\/openssl.BEKUP<\/p>\n<p>Create new environment files for OpenSSL.<\/p>\n<p class=\"command\">vim \/etc\/profile.d\/openssl.sh<\/p>\n<p>Paste configuration below.<\/p>\n<pre>#Set OPENSSL_PATH&#13;\nOPENSSL_PATH=\"\/usr\/local\/ssl\/bin\"&#13;\nexport OPENSSL_PATH&#13;\nPATH=$PATH:$OPENSSL_PATH&#13;\nexport PATH<\/pre>\n<p>Save and exit.<\/p>\n<p>Make the openssl.sh file executable.<\/p>\n<p class=\"command\">chmod +x \/etc\/profile.d\/openssl.sh<\/p>\n<p>Load the OpenSSL environment and check the PATH bin directory using commands below.<\/p>\n<p class=\"command\">source \/etc\/profile.d\/openssl.sh<br \/>echo $PATH<\/p>\n<p>Now check the OpenSSL file.<\/p>\n<p class=\"command\">which openssl<\/p>\n<p>You will get the result as below.<\/p>\n<p><a class=\"fancybox\" id=\"img-9\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_openssl_from_source_on_linux\/big\/9.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-the-latest-openssl-version-from-source-on-linux-8.png\" alt=\"Configure OpenSSL Binary on CentOS\" width=\"500\" height=\"288\" title=\"\"><\/a><\/p>\n<p>The binary path openssl for CentOS has been updated.<\/p>\n<h2 id=\"step-testing\">Step 4 &#8211; Testing<\/h2>\n<p>Test the OpenSSL new version using the following command.<\/p>\n<p class=\"command\">openssl version -a<\/p>\n<p>The result on Ubuntu.<\/p>\n<p><a class=\"fancybox\" id=\"img-101\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_openssl_from_source_on_linux\/big\/101.png\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-the-latest-openssl-version-from-source-on-linux-9.png\" alt=\"\" title=\"\"><\/a><\/p>\n<p>Result on CentOS.<\/p>\n<p><a class=\"fancybox\" id=\"img-112\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_openssl_from_source_on_linux\/big\/112.png\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-the-latest-openssl-version-from-source-on-linux-10.png\" alt=\"\" title=\"\"><\/a><\/p>\n<p>The new latest stable version of OpenSSL has been installed from source on Linux Ubuntu 18.04 and CentOS 7.5.<\/p>\n<p><a href=\"https:\/\/wiki.openssl.org\/index.php\/Compilation_and_Installation\" target=\"_blank\" rel=\"noopener\">https:\/\/wiki.openssl.org\/<\/a><\/p>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<p>\n<a href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fhow-to-install-openssl-from-source-on-linux%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-the-latest-openssl-version-from-source-on-linux-11.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fhow-to-install-openssl-from-source-on-linux%2F&amp;text=How+to+Install+the+latest+OpenSSL+version+from+Source+on+Linux&amp;via=howtoforgecom&amp;related=howtoforgecom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-the-latest-openssl-version-from-source-on-linux-12.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/howtoforgecom\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-the-latest-openssl-version-from-source-on-linux-13.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fhow-to-install-openssl-from-source-on-linux%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-the-latest-openssl-version-from-source-on-linux-14.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>OpenSSL is a widely used crypto library that implements SSL and TLS protocols\u00a0to secure communications over computer networks. OpenSSL is widely used by many software like Apache web server, PHP, Postfix and many others. OpenSSL offers support for different cryptographic algorithms such as Chipers (AES, Blowfish, DES, IDEA etc), Cryptographic hash functions (MD5, MD4, SHA-1, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-4836","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/4836","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=4836"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/4836\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=4836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=4836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=4836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}