Install a certificate for a website under Apache on Linux

From tech
Revision as of 10:51, 3 March 2023 by Lucazeo (talk | contribs) (Created page with "In this article, I will show you how to create and install a free SSL certificate for your domain. I will demonstrate how we did it for this very site. The example applies to a site installed on Apache, on a server where you have SSH access and root user privileges. In the example, we use the Debian 11 operating system. Also we have multiple domain under the same host, managed with VirtualHost. [https://httpd.apache.org/docs/2.4/vhosts/examples.html link to official doc...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

In this article, I will show you how to create and install a free SSL certificate for your domain. I will demonstrate how we did it for this very site. The example applies to a site installed on Apache, on a server where you have SSH access and root user privileges. In the example, we use the Debian 11 operating system.

Also we have multiple domain under the same host, managed with VirtualHost. link to official documentation.

  1. Connect to your server via SSH. For example:
    ssh myhostaddress.com
    
  2. Become root. Alternatively, you can use the sudo command before the commands we are going to use:
    sudo su -
    
  3. Install snapd:
    apt install snapd
    
  4. And do the basic configuration. For this example we are not going to deep explain every step, so just:
    snap install core
    snap refresh core
    
  5. In case you have a result like this:
    snap "core" has no updates available
    
    It is ok, go on.
  6. Clean eventually previous installations of certbot. Warning: do this only if you are sure nobody else needs it, or it can break previous scripts and so on:
    apt-get remove certbot
    
  7. Install certbot:
    snap install --classic certbot
    
  8. Create a link to make certbot usable from users:
    ln -s /snap/bin/certbot /usr/bin/certbot