Add LetsEncrypt to basic ServerPilot installation

Thanks to user fortminor from DigitalOcean community thread, I finally figured out how to add LetsEncrypt to basic ServerPilot installation. Lets walk through the step if you have DO droplet configured with ServerPilot.

First, run below script as su/root.

$ cd /usr/local/bin

$ wget https://raw.githubusercontent.com/lesaff/serverpilot-letsencrypt/master/sple.sh

$ chmod +x sple.sh

$ ./sple.sh

Above script will get the ServerPilot LetsEncrypt from GitHub.

After completing the wizard, add the autorenewal to crontab.

$ crontab -e

Insert below line to the crontab & save it.

0 */12 * * * letsencrypt renew && service nginx-sp reload

Then, navigate to nginx-sp vhost.d folder.

$ cd /etc/nginx-sp/vhosts.d

Edit your app’s ssl.conf & add below settings at top of the file. This to redirect http requests to https. Replace example.com with your domain.

server {
   listen 80;
   listen [::]:80;
   server_name example.com www.example.com;
   return 301 https://example.com$request_uri;
}

Backup your app’s conf & copy ssl.conf to .conf. This is to have a backup in case ServerPilot reset your app’s conf file.

$ mv example-app.conf example-app.conf.bak && cp example-app.ssh.conf example-app.conf

That’s it! Now restart nginx-sp service for the finishing move.

$ service nginx-sp restart

Here is the sample image used on this website.

Shazril Shohaimi

Certified tech nerd, who likes to meet people and discussing possibilities. Passionate at helping business grow in online. Friendliest person at Majiska Digital Solutions.