{"id":9849,"date":"2021-09-07T17:30:15","date_gmt":"2021-09-07T17:30:15","guid":{"rendered":"https:\/\/linuxways.net\/?p=9849"},"modified":"2021-09-07T17:30:15","modified_gmt":"2021-09-07T17:30:15","slug":"how-to-encrypt-apache-webserver-with-lets-encrypt-ssl-certificate-on-rocky-linux-8","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/red-hat\/how-to-encrypt-apache-webserver-with-lets-encrypt-ssl-certificate-on-rocky-linux-8\/","title":{"rendered":"How to Encrypt Apache Webserver with Let&#8217;s Encrypt SSL Certificate on Rocky Linux 8"},"content":{"rendered":"<p>In a world of constantly evolving cyber threats, securing your webserver should be top-of-the-mind concern. One of the easiest ways of boosting your web server\u2019s security is by securing it with an SSL certificate. The encrypts the traffic exchanged between the web server and users\u2019 browser and prevents hackers from eavesdropping and intercepting confidential information such as usernames and passwords.<\/p>\n<p><a href=\"https:\/\/letsencrypt.org\/\">Let\u2019s Encrypt<\/a> is a free and automated certificate authority that helps you to set up a secure HTTPS server using a free SSL certificate with a shelf life of approximately 90 days. In this guide, we will walk you through the process of securing your webserver using Let\u2019s Encrypt SSL certificate.<\/p>\n<h2><strong>Requirements<\/strong><\/h2>\n<p>As we get started, we assume that you already have the Apache webserver stack installed on your Rocky Linux 8. If not, check out this guide on how to <a href=\"https:\/\/linuxways.net\/de\/red-hat\/how-to-install-lamp-stack-on-rocky-linux\/\">install LAMP server on Rocky Linux 8<\/a>. The first step is a walkthrough of how to install Apache HTTP webserver.<\/p>\n<p>Additionally, ensure that you have a valid domain name pointing to your server\u2019s Public IP address. For this guide, we will be using the domain name called <strong>linuxtechgeek.info.<\/strong><\/p>\n<h2><strong>Step 1: Install EPEL repository<\/strong><\/h2>\n<p>Right off the bat, we will start with the installation of EPEL ( Extra Packages for Enterprise Linux ). This is a repository from Fedora that provides additional packages for RHEL-based systems.<\/p>\n<p>So, run the command show.<\/p>\n<pre><strong>$ sudo dnf install epel-release<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"1063\" height=\"279\" class=\"wp-image-9850\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-89.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-89.png 1063w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-89-300x79.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-89-1024x269.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-89-768x202.png 768w\" sizes=\"auto, (max-width: 1063px) 100vw, 1063px\" \/><\/strong><\/p>\n<h2><strong>Step 2: Install Certbot<\/strong><\/h2>\n<p>Once EPEL is installed, go ahead and install <strong>certbot<\/strong> , the apache module for certbot and <strong>mod_ssl<\/strong> which is a module that provides cryptographic features for Apache.<\/p>\n<pre><strong>$ sudo dnf install certbot python3-certbot-apache mod_ssl<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"1066\" height=\"282\" class=\"wp-image-9851\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-90.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-90.png 1066w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-90-300x79.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-90-1024x271.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-90-768x203.png 768w\" sizes=\"auto, (max-width: 1066px) 100vw, 1066px\" \/><\/strong><\/p>\n<p>After the installation of the packages, restart the Apache HTTP web server.<\/p>\n<pre><strong>$ sudo systemctl restart httpd <\/strong><\/pre>\n<p>In addition, ensure that the webserver is running:<\/p>\n<pre><strong>$ sudo systemctl status httpd <\/strong><\/pre>\n<h2><strong>Step 3 : Create virtualhost file<\/strong><\/h2>\n<p>The next step it configure an Apache virtual host file. This is a configuration that will serve our domain\u2019s web content and will be used by certbot to facilitate the installation of Let\u2019s Encrypt.<\/p>\n<p>So, create a folder for your website. In this case, I will create a directory for <strong>linuxtechgeek.info <\/strong>which is my domain name pointed to the IP of my webserver.<\/p>\n<pre><strong>$ sudo mkdir -p \/var\/www\/linuxtechgeek.info<\/strong><\/pre>\n<p>Assign the directory ownership to Apache user.<\/p>\n<pre><strong>$ sudo chown -R apache:apache \/var\/www\/linuxtechgeek.info<\/strong><\/pre>\n<p>Next, create a virtual host file in the <strong>\/etc\/httpd\/conf.d <\/strong>directory.<\/p>\n<pre><strong>$ sudo vim \/etc\/httpd\/conf.d\/linuxtechgeek.info.conf<\/strong><\/pre>\n<p>Paste the configuration shown and be sure to replace <strong>linuxtechgeek.info <\/strong>with your own domain name<\/p>\n<pre><strong>&lt;virtualhost *:80&gt;<\/strong>\r\n\r\n<strong>ServerName linuxtechgeek.info<\/strong>\r\n\r\n<strong>ServerAlias www.linuxtechgeek.info<\/strong>\r\n\r\n<strong>DocumentRoot \/var\/www\/linuxtechgeek.info<\/strong>\r\n\r\n<strong>ErrorLog \/var\/log\/httpd\/linuxtechgeek.info-error.log<\/strong>\r\n\r\n<strong>CustomLog \/var\/log\/httpd\/linuxtechgeek.info-access.log combined<\/strong>\r\n\r\n<strong>&lt;\/virtualhost&gt;<\/strong><\/pre>\n<p>Save and exit the configuration file. Then restart Apache webserver.<\/p>\n<pre><strong>$ sudo systemctl restart httpd<\/strong><\/pre>\n<p>Let\u2019s now obtain the SSL certificate.<\/p>\n<h2><strong>Step 4 : Obtain the SSL certificate<\/strong><\/h2>\n<p>Finally, to install Let\u2019s Encrypt using Certbot, run the following command:<\/p>\n<pre><strong>$ sudo certbot --apache<\/strong><\/pre>\n<p>This walks you through a series of steps to configure the SSL certificate, provide your email address, read and agree the terms of service and choose which names you would want to activate HTTPS on.<\/p>\n<p>Certbot will detect your virtual host configuration and request the Let\u2019s Encrypt SSL certificate for all of them.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1026\" height=\"633\" class=\"wp-image-9852\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-91.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-91.png 1026w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-91-300x185.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-91-1024x632.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-91-768x474.png 768w\" sizes=\"auto, (max-width: 1026px) 100vw, 1026px\" \/><\/p>\n<p>Once certbot is done applying the SSL certificate on your webserver, proceed and test the SSL settings by performing an SSL server test at <a href=\"https:\/\/www.ssllabs.com\/ssltest\/\">SSL Labs<\/a>. This is an online platform that performs a deep analysis your site\u2019s web server.<\/p>\n<h2><strong>Step 5: Configure certificate auto-renewal<\/strong><\/h2>\n<p>As mentioned earlier, Let\u2019s Encrypt certificate is only valid for 90 days, after which you will be required to renew it. You can renew the certificate manually a day before the expiration using the command:<\/p>\n<pre><strong>$ certbot renew <\/strong><\/pre>\n<p>A better approach would be to set up a cron job what will automate the certificate\u2019s renewal process. So, open the crontab file.<\/p>\n<pre><strong>$ crontab -e<\/strong><\/pre>\n<p>Add this line at the very end of the file and save the changes.<\/p>\n<pre><strong>0 0 * * * \/usr\/bin\/certbot renew &gt; \/dev\/null 2&gt;&amp;1<\/strong><\/pre>\n<p>And it\u2019s a wrap. Hopefully you are now at ease securing your Apache webserver with Let\u2019s Encrypt SSL certificate.<\/p>","protected":false},"excerpt":{"rendered":"<p>In a world of constantly evolving cyber threats, securing your webserver should be top-of-the-mind concern. One of the easiest ways of boosting your web server\u2019s security is by&hellip;<\/p>","protected":false},"author":1,"featured_media":9890,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[165],"tags":[178,436,432],"class_list":["post-9849","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-red-hat","tag-apache","tag-rocky-linux-8","tag-ssl-certificate"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/9849","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=9849"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/9849\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/9890"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=9849"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=9849"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=9849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}