How Do I Add a Let’s Encrypt Certificate to My Unmanaged VPS?

Author:

Published:

Updated on August 15, 2024

Reading Time: 1 min read

How to Install Free SSL on VPS #

Unlike shared web hosting platforms, some manual intervention is required to enable and install Let’s Encrypt certificates on a CP CLOUD HOSTING Unmanaged VPS using StackCP. The process depends on the operating system in use and whether you are using a control panel, such as cPanel.

Using cPanel #

To install a Let’s Encrypt SSL on a cPanel VPS, follow these steps:

  1. Login to the VPS via SSH.
  2. Run the following command (preferably as root or a user with sudo access):

/scripts/install_lets_encrypt_autossl_provider

  1. This command installs the Let’s Encrypt plugin.
  2. Access WHM interface:
    • Navigate to Home > SSL/TLS > Manage AutoSSL.
    • Select Let’s Encrypt from the list of available AutoSSL providers.
    • Agree to the terms of service and click ‘Save’.
  3. Issue Certificates:
    • Use the ‘Run AutoSSL For All Users’ option to issue certificates for all users.
    • Alternatively, issue certificates on a user-by-user basis by selecting ‘Manage Users’ on the ‘Manage AutoSSL’ page.

Using Certbot on CentOS 6 #

For those without a control panel, Let’s Encrypt certificates can be installed using Certbot. Follow these steps:

  1. Access the VPS via SSH as root or a user with sudo privileges.
  2. Run the following commands to install Certbot:

wget https://dl.eff.org/certbot-auto
sudo mv certbot-auto /usr/local/bin/certbot-auto
sudo chown root /usr/local/bin/certbot-auto
sudo chmod 0755 /usr/local/bin/certbot-auto

Run Certbot:

  • For Apache setup:

sudo /usr/local/bin/certbot-auto –apache

For Nginx setup:

sudo /usr/local/bin/certbot-auto --nginx

Follow the prompts to enter your email, accept the terms of service, and select the domains to secure.

Set up a cron job to ensure automatic renewal of the certificate:

echo "0 0,12 * * * root python -c 'import random; import time; time.sleep(random.random() * 3600)' && /usr/local/bin/certbot-auto renew" | sudo tee -a /etc/crontab > /dev/null

Using Certbot on CentOS 7
For CentOS/RHEL 7, the setup is slightly different:

Enable the Extra Packages for Enterprise Linux (EPEL) repository:

sudo yum install epel-release

Install Certbot:

For Apache servers:
sudo yum install certbot python2-certbot-apache

For Nginx:
sudo yum install certbot python2-certbot-nginx

Run Certbot:For Apache:
sudo certbot --apache

For Nginx:
sudo certbot --nginx

Follow the prompts to enter your email, accept the terms of service, and select the domains to secure.

Set up a cron job to ensure automatic renewal of the certificate:

echo "0 0,12 * * * root python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew" | sudo tee -a /etc/crontab > /dev/null

By following these steps, you can successfully add a Let's Encrypt SSL certificate to your Unmanaged VPS on CP CLOUD HOSTING.