Letsencrypt SSL on ServerPilot Free Plan

The paid plan of ServerPilot is priced at $10 per month which allows you to enable Let’s Encrypt SSL with a single click. But if you don’t want to spend that $10 and still need to enable SSL on your apps, then you can use a simple bash script that I’ve written a few months ago. This bash script allows you to get a free SSL certificate for your domains from Let’s Encrypt. As the SSLs from Let’s Encrypt are valid for 3 months, so you have to renew the SSLs every 3 months. Don’t worry, you will not need to perform the renewal yourself as the script adds a CRON job that will renew your expiring SSLs every month.

How to Install the SSL:

In short, there are 3 simple steps to install Let’s Encrypt free SSL on your ServerPilot server:

  1. Sign in to your server as root via SSH
  2. Clone my repository from GitHub
  3. Execute the command to install the SSL

It’s that simple. You don’t need to create virtual host files or you don’t need to configure any CRON jobs for auto-renewal of the certs. Everything is automated and the script will install and configure the SSL for you.

Now let’s talk in a little depth about all this process.

First of all, sign into your server via SSH as root and execute this command:

sudo git clone https://github.com/rehmatworks/serverpilot-letsencrypt.git && cd serverpilot-letsencrypt && sudo mv sple.sh /usr/local/bin/rwssl && sudo chmod +x /usr/local/bin/rwssl && (crontab -l ; echo "@monthly \"sudo service nginx-sp stop && yes | letsencrypt renew &>/dev/null && service nginx-sp start && service nginx-sp reload\"")| crontab - && service cron reload

If you get an error saying that ‘git’ command isn’t available, then you will have to install it by typing ‘apt-get install git’.

Once you will execute the command I mentioned above, the bash script will be copied to your server and will be made executable via a command rwssl. Moreover, the auto-renewal CRON job will be added as well. Now you can start installing SSL certs for your sites by executing the script like this:

For Main Domains:

rwssl install example.com app_name main

For Sub Domains:

rwssl install sub.example.com app_name sub

P.S.: You will have to replace the red highlighted values (domain name and app name) with real values.

That’s it. SSL will be installed if all goes well. In case you get any errors during all this process, ensure that you are logged in as the root user or a sudoer as well as your domain is already pointing to your server. If your domain’s DNS isn’t pointed to your server, then Let’s Encrypt will unable to verify your ownership of the domain and it will not issue the cert.

The script for this ServerPilot SSL automation is hosted at GitHub here. Don’t forget to give it a star if this helps you :). Do you have any questions? Ask below in comments.

Rehmat

A web developer, server administrator and a blogger from Gilgit-Baltistan, Pakistan.

Post A Reply