{"id":16103,"date":"2023-06-21T22:03:13","date_gmt":"2023-06-21T22:03:13","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=16103"},"modified":"2023-10-03T05:16:17","modified_gmt":"2023-10-03T05:16:17","slug":"how-to-enable-mod_ssl-apache-module-on-ubuntu","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-enable-mod_ssl-apache-module-on-ubuntu\/","title":{"rendered":"How to Enable mod_ssl Apache module on Ubuntu"},"content":{"rendered":"<p><img decoding=\"async\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Enable-mod_ssl-Apache-module-on-Ubuntu-1024x768.jpg\" alt=\"How to Enable mod_ssl Apache module on Ubuntu\" width=\"1024\" height=\"768\" class=\"alignnone size-large wp-image-16104 lazyload\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Enable-mod_ssl-Apache-module-on-Ubuntu-1024x768.jpg 1024w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Enable-mod_ssl-Apache-module-on-Ubuntu-300x225.jpg 300w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Enable-mod_ssl-Apache-module-on-Ubuntu-1536x1152.jpg 1536w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Enable-mod_ssl-Apache-module-on-Ubuntu-2048x1536.jpg 2048w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Enable-mod_ssl-Apache-module-on-Ubuntu-128x96.jpg 128w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Enable-mod_ssl-Apache-module-on-Ubuntu-420x315.jpg 420w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Enable-mod_ssl-Apache-module-on-Ubuntu-540x405.jpg 540w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Enable-mod_ssl-Apache-module-on-Ubuntu-720x540.jpg 720w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Enable-mod_ssl-Apache-module-on-Ubuntu-960x720.jpg 960w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Enable-mod_ssl-Apache-module-on-Ubuntu-1140x855.jpg 1140w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Enable-mod_ssl-Apache-module-on-Ubuntu-1320x990.jpg 1320w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Enable-mod_ssl-Apache-module-on-Ubuntu-1440x1080.jpg 1440w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/768;\" \/><\/p>\n<p><a href=\"https:\/\/webhostinggeeks.com\/blog\/apache-http-server-explained\/\">Apache HTTP Server<\/a> is an open-source <a href=\"https:\/\/webhostinggeeks.com\/best\/web-server\/\">web server software<\/a> that is fast, reliable, and secure. It can be highly customized to meet the needs of many different environments by using extension modules and scripts. One of the most common modules used is the mod_ssl module which provides necessary support for <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-ssl-secure-sockets-layer-technology-explained\/\">SSL<\/a> and <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-tls-transport-layer-security-explained\/\">TLS<\/a> protocols.<\/p>\n<p>SSL\/TLS is a protocol used to secure and encrypt communication between computers. In web servers and hosting, it&#8217;s used to secure data transfer between the server and the client (browser). When SSL is enabled and configured on your server, it changes the HTTP to HTTPS, indicating that a secure connection is in place.<\/p>\n<p>In this tutorial, we will learn how to enable the mod_ssl Apache module on <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-ubuntu-beginners-guide-ubuntu-linux-distro\/\">Ubuntu Linux OS<\/a>.<\/p>\n<p>This tutorial is designed for webmasters and website administrators who have a basic understanding of how web servers work. It&#8217;s also beneficial if you have some experience with command-line operations in Linux, as we&#8217;ll be using the terminal to execute commands.<\/p>\n<p>Let&#8217;s get started!<\/p>\n<h2>Prerequisites<\/h2>\n<p>Before we start, you need to have the following:<\/p>\n<ol>\n<li>A Ubuntu server: You can use a <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-dedicated-server-hosting\/\">dedicated server<\/a>, <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-vps-hosting\/\">VPS server<\/a>, or a <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-cloud-hosting\/\">cloud hosting<\/a> service. The choice depends on your preference, budget, and level of comfort with managing servers.<\/li>\n<li>Apache installed: If you haven&#8217;t installed Apache yet, you can follow our guide on the <a href=\"https:\/\/webhostinggeeks.com\/howto\/how-to-install-apache-httpd-web-server-on-linux\/\">Apache HTTP Server Installation<\/a>.<\/li>\n<li>Terminal access: You need to be able to log in to your server&#8217;s terminal. This can be done directly if you&#8217;re using a dedicated server, or via SSH if you&#8217;re using a remote server.<\/li>\n<li>Sudo privileges: The account you&#8217;re using to log in to the server needs to have sudo privileges so that you can perform administrative tasks.<\/li>\n<\/ol>\n<p>Once you have these in place, we can proceed with the tutorial.<\/p>\n<h2>Step 1: Update Your Server<\/h2>\n<p>The first step is to ensure that your server is up-to-date. You can do this by running the following commands:<\/p>\n<pre>\r\nsudo apt-get update\r\nsudo apt-get upgrade\r\n<\/pre>\n<p>These commands will update the package lists for upgrades and new package installations, and install the newest versions of all packages currently installed on your system.<\/p>\n<h2>Step 2: Install mod_ssl<\/h2>\n<p>The next step is to install the mod_ssl module. This can be done using the following command:<\/p>\n<pre>\r\nsudo apt-get install libapache2-mod-ssl\r\n<\/pre>\n<p>This command will install the mod_ssl module along with its dependencies.<\/p>\n<h2>Step 3: Enable mod_ssl<\/h2>\n<p>After the installation is complete, you need to enable the mod_ssl module. This can be done using the following command:<\/p>\n<pre>\r\nsudo a2enmod ssl\r\n<\/pre>\n<p>The a2enmod command is used to enable Apache modules. <\/p>\n<h2>Step 4: Set Up SSL Certificate<\/h2>\n<p>Once the mod_ssl module is enabled, the next step is to set up an SSL certificate. For the purpose of this tutorial, we will create a self-signed certificate. This type of certificate is fine for testing purposes or for internal use, but for a public website, you should consider getting a certificate signed by a trusted certificate authority.<\/p>\n<p>You can create a self-signed certificate using the <a href=\"https:\/\/webhostinggeeks.com\/blog\/openssl-explained-in-simple-terms\/\">openssl<\/a> command as follows:<\/p>\n<pre>\r\nsudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout \/etc\/ssl\/private\/apache-selfsigned.key -out \/etc\/ssl\/certs\/apache-selfsigned.crt\r\n<\/pre>\n<p>This command will create a new RSA key and a self-signed certificate valid for 365 days. The key will be stored in the file \/etc\/ssl\/private\/apache-selfsigned.key and the certificate in the file \/etc\/ssl\/certs\/apache-selfsigned.crt.<\/p>\n<p>During the execution of this command, you will be asked several questions about your server and your organization. The most important question is &#8220;Common Name (e.g. server FQDN or YOUR name)&#8221;. Here you should enter the domain name of your server or, if you don&#8217;t have one, your server&#8217;s public IP address.<\/p>\n<h2>Step 5: Configure Apache to Use SSL<\/h2>\n<p>Now that you have your SSL certificate, you need to configure Apache to use it. This involves editing the default SSL configuration file.<\/p>\n<p>First, open the file with a text editor. In this example, we&#8217;ll use nano:<\/p>\n<pre>\r\nsudo nano \/etc\/apache2\/sites-available\/default-ssl.conf\r\n<\/pre>\n<p>In this file, look for the lines that start with SSLCertificateFile and SSLCertificateKeyFile. Replace them with the following lines:<\/p>\n<pre>\r\nSSLCertificateFile \/etc\/ssl\/certs\/apache-selfsigned.crt\r\nSSLCertificateKeyFile \/etc\/ssl\/private\/apache-selfsigned.key\r\n<\/pre>\n<p>These lines tell Apache where to find the SSL certificate and the private key.<\/p>\n<h2>Step 6: Enable the SSL Site<\/h2>\n<p>The next step is to enable the SSL site. This can be done using the a2ensite command as follows:<\/p>\n<pre>\r\nsudo a2ensite default-ssl\r\n<\/pre>\n<p>The a2ensite command is used to enable Apache sites.<\/p>\n<h2>Step 7: Restart Apache<\/h2>\n<p>Finally, for the changes to take effect, you need to restart Apache. This can be done using the following command:<\/p>\n<pre>\r\nsudo systemctl restart apache2\r\n<\/pre>\n<p>Congratulations! You have successfully enabled the mod_ssl Apache module on your Ubuntu server. Your server is now capable of serving websites over HTTPS, providing a secure connection for your users.<\/p>\n<h2>Conclusion<\/h2>\n<p>In this tutorial, we&#8217;ve walked through the process of enabling the mod_ssl Apache module on Ubuntu. This module is crucial for securing your web server and ensuring that data transferred between the server and client is encrypted. While the process may seem complex, it&#8217;s actually quite straightforward when broken down into individual steps. By following this guide, even beginners should be able to secure their Apache server with SSL.<\/p>\n<p>Remember, while a self-signed certificate is fine for testing purposes or internal use, for a public website, you should consider getting a certificate signed by a trusted certificate authority. This ensures that your users&#8217; browsers will trust your site and not display any warning messages.<\/p>\n<p>For more information on different types of web servers, you can visit our guide on the <a href=\"https:\/\/webhostinggeeks.com\/best\/web-server\/\">best web servers<\/a>.<\/p>\n<p>If you have any questions or run into any issues, feel free to ask for help. There&#8217;s a large and active community of Apache users who can provide assistance.<\/p>\n<p>Good luck with your Apache server!<\/p>\n<h2>Commands Mentioned<\/h2>\n<ul>\n<li><span class=\"fw-bold\">sudo apt-get update<\/span> \u2013 Updates the package lists for upgrades and new package installations.<\/li>\n<li><span class=\"fw-bold\">sudo apt-get upgrade<\/span> \u2013 Installs the newest versions of all packages currently installed on the system.<\/li>\n<li><span class=\"fw-bold\">sudo apt-get install libapache2-mod-ssl<\/span> \u2013 Installs the mod_ssl module along with its dependencies.<\/li>\n<li><span class=\"fw-bold\">sudo a2enmod ssl<\/span> \u2013 Enables the mod_ssl module.<\/li>\n<li><span class=\"fw-bold\">sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout \/etc\/ssl\/private\/apache-selfsigned.key -out \/etc\/ssl\/certs\/apache-selfsigned.crt<\/span> \u2013 Creates a new RSA key and a self-signed certificate valid for 365 days.<\/li>\n<li><span class=\"fw-bold\">sudo nano \/etc\/apache2\/sites-available\/default-ssl.conf<\/span> \u2013 Opens the default SSL configuration file in a text editor.<\/li>\n<li><span class=\"fw-bold\">sudo a2ensite default-ssl<\/span> \u2013 Enables the SSL site.<\/li>\n<li><span class=\"fw-bold\">sudo systemctl restart apache2<\/span> \u2013 Restarts Apache.<\/li>\n<\/ul>\n<h2>FAQ<\/h2>\n<ol itemscope itemtype=\"https:\/\/schema.org\/FAQPage\">\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is the mod_ssl Apache module?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">The mod_ssl module provides support for SSL and TLS protocols on the Apache web server. It allows the server to serve sites over HTTPS, providing a secure connection for users.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is a self-signed SSL certificate?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">A self-signed SSL certificate is a certificate that is not signed by a trusted certificate authority. Instead, it is signed by the server that generated it. While it provides the same level of encryption as a certificate signed by a trusted authority, it is not trusted by browsers and will usually trigger a warning message. It&#8217;s fine for testing purposes or for internal use, but for a public website, a certificate signed by a trusted authority is recommended.<\/span>\n<\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">Why do I need to restart Apache after enabling mod_ssl?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">Restarting Apache ensures that the server picks up any changes you&#8217;ve made to its configuration files. When you enable mod_ssl, you&#8217;re making changes to Apache&#8217;s configuration. By restarting the server, you&#8217;re making sure that these changes are applied.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is the difference between HTTP and HTTPS?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">HTTP stands for Hypertext Transfer Protocol, and it&#8217;s the protocol used for transferring data over the internet. HTTPS stands for HTTP Secure. It&#8217;s the same as HTTP, but it uses an SSL certificate to encrypt the data that is transferred between the server and the client. This makes it much more secure.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What does the a2enmod command do?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">The a2enmod command is used to enable Apache modules. The name stands for &#8220;Apache 2 enable module&#8221;. When you run this command followed by the name of a module, it enables that module.<\/span>\n            <\/p>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Apache HTTP Server is an open-source web server software that is fast, reliable, and secure. It can be highly customized to meet the needs of many different environments by using&#8230;<\/p>\n","protected":false},"author":6,"featured_media":16104,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[1103,1073],"tags":[1199,2079,2078,1856],"class_list":["post-16103","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apache","category-ubuntu","tag-apache","tag-apache-module","tag-mod_ssl","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/16103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=16103"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/16103\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/16104"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=16103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=16103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=16103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}