How To Install Free SSL On A VPS Using Certbot

Are you looking to install a free Let’s Encrypt SSL on your VPS operating system? Don’t worry, we’ve got you covered. Follow these simple steps:

Step 1 – Prepare the VPS

Before we begin installing the SSL, let’s make sure your VPS meets the following criteria:

  • Your VPS should have a web server running, such as Apache or NGINX.
  • The website hosted on your VPS should be accessible via the domain name and not just the IP address.
  • Ensure that your domain is fully propagated and pointing to your VPS child nameservers. Installing an SSL while the domain is still propagating may result in a self-signed certificate, causing potential errors when accessing your website.

Step 2 – Install Dependencies

Certbot, the tool we’ll be using, recommends using Snapd for installation. However, since Hostinger Linux-based VPS doesn’t support snaps, we’ll use Python instead. Here’s what you need to do:

For APT-based distributions (Debian, Ubuntu):

sudo apt updatesudo apt install python3 python3-venv libaugeas0

For RPM-based distributions (Fedora, CentOS):

sudo dnf install python3 augeas-libs

Please note:

  • If you’re using an older distribution without dnf, use yum instead.
  • Some RHEL-based distributions may require python3x instead of python3 (e.g., python38). Please refer to your Linux distribution’s documentation for specifics.

Step 3 – Install Certbot

To avoid conflicts with previous versions, remove any existing Certbot packages before installing the latest version. You can use your package manager (apt, dnf, yum, etc.) for this task.

Once you’ve cleared the way, follow these steps:

1. Set up a Python virtual environment:

sudo python3 -m venv /opt/certbot/sudo /opt/certbot/bin/pip install –upgrade pip

2. Install Certbot for Apache:

sudo /opt/certbot/bin/pip install certbot certbot-apache

Or install Certbot for NGINX:

sudo /opt/certbot/bin/pip install certbot certbot-nginx

3. Create a symbolic link for easy execution:

sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot

4. Install and activate SSL for your websites. Let Certbot handle the configurations automatically. Use the following command for Apache:

sudo certbot –apache

Or use this command for NGINX:

sudo certbot –nginx

Note:

  • If you prefer obtaining only the certificates and configuring the SSL manually, add “certonly” after certbot and before –apache or –nginx.
  • To ensure your SSL remains valid beyond the initial 90-day period, we recommend setting up automatic renewal. Execute the following command:
echo 0 0,12 * * * root /opt/certbot/bin/python -c ‘import random; import time; time.sleep(random.random() * 3600)’ && sudo certbot renew -q | sudo tee -a /etc/crontab > /dev/null

That’s it! You can now open your website in an incognito window to verify that the SSL is installed and functioning correctly

Leave A Comment?