{"id":22279,"date":"2024-09-17T14:47:58","date_gmt":"2024-09-17T12:47:58","guid":{"rendered":"https:\/\/contabo.com\/blog\/kb\/103000301786-%e2%81%a0%e2%81%a0how-do-i-install-ssl-certificates-on-apache\/"},"modified":"2025-04-10T18:10:03","modified_gmt":"2025-04-10T16:10:03","slug":"103000301786-%e2%81%a0%e2%81%a0how-do-i-install-ssl-certificates-on-apache","status":"publish","type":"kb","link":"https:\/\/contabo.com\/blog\/kb\/103000301786-%e2%81%a0%e2%81%a0how-do-i-install-ssl-certificates-on-apache\/","title":{"rendered":"\u2060\u2060How Do I Install SSL Certificates on Apache?"},"content":{"rendered":"<h4 dir=\"ltr\"><strong>How do I install SSL on Apache?<\/strong><\/h4>\n<ol>\n<li dir=\"ltr\">Firstly you will need to install Apache if it is not already installed on your server. You can install Apache with the following commands:\n<ol>\n<li dir=\"ltr\">Update your package list with this command:\n<pre>sudo apt update<\/pre>\n<\/li>\n<li dir=\"ltr\">Install Apache with this command:\n<pre>sudo apt install apache2<\/pre>\n<\/li>\n<li dir=\"ltr\">Check that Apache is running with these commands:\n<pre>sudo systemctl start apache\nsudo systemctl enable apache\nsudo systemctl status apache2 <\/pre>\n<\/li>\n<\/ol>\n<\/li>\n<li dir=\"ltr\">Next install the SSL module for Apache with these commands:\n<pre>sudo a2enmod ssl \nsudo systemctl restart apache2<\/pre>\n<\/li>\n<li dir=\"ltr\">Now you&#8217;ll need to configure the SSL certificates.\n<ol>\n<li dir=\"ltr\">First create a directory to store your SSL certificates:\n<pre>sudo mkdir -p \/etc\/apache2\/ssl<\/pre>\n<\/li>\n<li dir=\"ltr\">Next you&#8217;ll need to copy your certificates to the directory you just created.\n<p>Assuming your certificates are on your local machine, and you are using Windows OS on your local machine, you can use WinSCP to upload certificate files to previously created directory \/etc\/apache2\/ssl.<\/p>\n<p>In case you are using Linux distribution on your local machine, you can use scp totransfer them to the server.<\/p>\n<p>Replace &#8220;your_username&#8221; and &#8220;your_server_ip&#8221; in the example below with your actual username and server IP address and run the 3 commands separately:<\/p>\n<pre>scp \/path\/to\/your\/certificate.crt your_username@your_server_ip:\/etc\/apache2\/ssl\/&nbsp;<\/pre>\n<pre>scp \/path\/to\/your\/certificate.key your_username@your_server_ip:\/etc\/apache2\/ssl\/ <\/pre>\n<pre>scp \/path\/to\/your\/certificate_chain.crt your_username@your_server_ip:\/etc\/apache2\/ssl\/<\/pre>\n<\/li>\n<li dir=\"ltr\">Then set the permissions for these certificates:\n<pre>sudo chmod 600 \/etc\/apache2\/ssl\/certificate.key<\/pre>\n<\/li>\n<\/ol>\n<\/li>\n<li dir=\"ltr\">Next you&#8217;ll need to configure Apache to use SSL.&nbsp;You&#8217;ll need to create or modify the virtual host configuration for your site to use SSL.&nbsp;\n<ol>\n<li dir=\"ltr\">Create a new configuration file for your SSL site or edit the default one:\n<pre>sudo nano \/etc\/apache2\/sites-available\/your_domain_ssl.conf<\/pre>\n<p>Please note that you can use vi, nano or any other text editor of your choice.<\/p>\n<p>Replace &#8220;your_domain_ssl.conf&#8221; with your desired config filename, for example, &#8220;default-ssl.conf&#8221; if you&#8217;re editing the default one.<\/li>\n<li dir=\"ltr\">Add or modify the following configuration to the textfile that is opened:\n<pre>&lt;VirtualHost *:443&gt; \n&nbsp; &nbsp; &nbsp; &nbsp;ServerAdmin <a href=\"\/cdn-cgi\/l\/email-protection\" rel=\"nofollow\" class=\"__cf_email__\" data-cfemail=\"dba2b4aea984beb6bab2b79bbea3bab6abb7bef5b8b4b6\">[email&nbsp;protected]<\/a>&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;ServerName your_domain.com&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;ServerAlias www.your_domain.com&nbsp;\n&nbsp;&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;DocumentRoot \/var\/www\/html&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;SSLEngine on&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;SSLCertificateFile \/etc\/apache2\/ssl\/certificate.crt&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;SSLCertificateKeyFile \/etc\/apache2\/ssl\/certificate.key&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;SSLCertificateChainFile \/etc\/apache2\/ssl\/certificate_chain.crt&nbsp;\n&nbsp;&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;&lt;Directory \/var\/www\/html&gt;&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Options Indexes FollowSymLinks&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AllowOverride All&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Require all granted&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;&lt;\/Directory&gt;&nbsp;\n&nbsp;&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;ErrorLog ${APACHE_LOG_DIR}\/error.log&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp;CustomLog ${APACHE_LOG_DIR}\/access.log combined&nbsp;\n&nbsp; &nbsp;&lt;\/VirtualHost&gt;\nEnsure that \"SSLCertificateFile\", \"SSLCertificateKeyFile\", and \"SSLCertificateChainFile\" point to the correct paths of your certificate files. \n<\/pre>\n<\/li>\n<li dir=\"ltr\">Enable the SSL site with the following command:\n<pre>sudo a2ensite your_domain_ssl.conf&nbsp;<\/pre>\n<\/li>\n<li dir=\"ltr\">(optional) Disable the default HTTP site if you want:\n<pre>sudo a2dissite 000-default.conf&nbsp;<\/pre>\n<\/li>\n<li dir=\"ltr\">Restart Apache to apply changes:\n<pre>sudo systemctl reload apache2 <\/pre>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p dir=\"ltr\"><strong><em>Optionally you can also redirect HTTP to HTTPS with the following steps:<\/em><\/strong><\/p>\n<p dir=\"ltr\">To redirect all HTTP traffic to HTTPS, you can add the following to your non-SSL virtual host configuration (usually in &#8220;000-default.conf&#8221;):<\/p>\n<pre>&lt;VirtualHost *:80&gt; \n&nbsp; &nbsp; ServerAdmin <a href=\"\/cdn-cgi\/l\/email-protection\" rel=\"nofollow\" class=\"__cf_email__\" data-cfemail=\"037a6c76715c666e626a6f43667b626e736f662d606c6e\">[email&nbsp;protected]<\/a>&nbsp;\n&nbsp; &nbsp; ServerName your_domain.com&nbsp;\n&nbsp; &nbsp; ServerAlias www.your_domain.com&nbsp;\n&nbsp;&nbsp;\n&nbsp; &nbsp; DocumentRoot \/var\/www\/html&nbsp;\n&nbsp;&nbsp;\n&nbsp; &nbsp; RewriteEngine On&nbsp;\n&nbsp; &nbsp; RewriteCond %{HTTPS} off&nbsp;\n&nbsp; &nbsp; RewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [L,R=301]&nbsp;\n&nbsp;&nbsp;\n&nbsp; &nbsp; ErrorLog ${APACHE_LOG_DIR}\/error.log&nbsp;\n&nbsp; &nbsp; CustomLog ${APACHE_LOG_DIR}\/access.log combined&nbsp;\n&lt;\/VirtualHost&gt; <\/pre>\n<p dir=\"ltr\">Then, enable the &#8220;rewrite&#8221; module and restart Apache:<\/p>\n<pre>sudo a2enmod rewrite \nsudo systemctl restart apache2 <\/pre>\n<p dir=\"ltr\">Now, your website should be accessible over HTTPS using your SSL certificates.&nbsp;<\/p>\n<p dir=\"ltr\"><\/p>\n<p dir=\"ltr\">You can read more about SSL on our <a href=\"https:\/\/contabo.com\/blog\/ultimate-guide-to-ssl\/\" target=\"_blank\" rel=\"noopener\"><u>blog here<\/u><\/a>.<\/p>\n<\/p>\n<p><span class=\"ast-load-more active\"><a href=\"https:\/\/help.contabo.com\/en\/support\/solutions\/articles\/103000301786-\u2060\u2060how-do-i-install-ssl-certificates-on-apache-\" rel=\"nofollow\">Details&#8230;<\/a> <\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How do I install SSL on Apache? Firstly you will need to install Apache if it is not already installed on your server. You can install Apache with the following commands: Update your package list with this command: sudo apt update Install Apache with this command: sudo apt install apache2 Check that Apache is running [&hellip;]<\/p>\n","protected":false},"author":72,"featured_media":0,"template":"","meta":{"inline_featured_image":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[2067],"tags":[],"class_list":["post-22279","kb","type-kb","status-publish","hentry","category-kb"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Contabo Web","author_link":"https:\/\/contabo.com\/blog\/author\/julius-nalivaiko\/"},"uagb_comment_info":0,"uagb_excerpt":"How do I install SSL on Apache? Firstly you will need to install Apache if it is not already installed on your server. You can install Apache with the following commands: Update your package list with this command: sudo apt update Install Apache with this command: sudo apt install apache2 Check that Apache is running&hellip;","_links":{"self":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb\/22279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/users\/72"}],"version-history":[{"count":1,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb\/22279\/revisions"}],"predecessor-version":[{"id":22950,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb\/22279\/revisions\/22950"}],"wp:attachment":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/media?parent=22279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/categories?post=22279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/tags?post=22279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}