Let's Encrypt on Shared Hosting (namecheap)
Here’s a look at adding Let’s Encrypt to a shared hosting platform.
Shared hosting platforms (like ‘namecheap’) want you to purchase their SSL certificates. But, we all know there are free SSL Certificate providers out there, like Let’s Encrypt (LE). LE let’s you use the command line to generate and use LE certificates. However, it gets a bit tricky on shared hosting platforms. Inspired by this post (which needs to be updated, hense my motivation for my post), here are the steps to accomplish this task.
IMPORTANT: When you issue the certificate (STEP 4), you MUST use --server letsencrypt
1) Enable SSH (there are instructions on namecheap to enable ssh in CPanel)
2) Get the certificates
#Get acme.sh utility
curl https://get.acme.sh | sh
#Source the Environment variables
source ~/.bashrc
#Register your email with Lets's Encrypt to be notified any renewals issue
acme.sh --register-account --accountemail email@example.com
# At this moment a cron entry already has been setup for autorenewal which will auto renew after 60 days., You can update /dev/null to something like this if you need the log
crontab -l | grep acme.sh
10 0 * * * "/home/_CPANEL_USERNAME_/.acme.sh"/acme.sh --cron --home "/home/_CPANEL_USERNAME_/.acme.sh" >> /home/_CPANEL_USERNAME_/.acme_cron_log
3) Issue a test cert to check if all working
#webroot will be any directory in which your domain exist, give path accordingly.
acme.sh --issue --webroot ~/public_html -d yourdomain.com --staging
4) Issue an actual Certificate
acme.sh --issue --webroot ~/public_html -d yourdomain.com --force --server letsencrypt
#In ourput you will see success if all goes fine & key/Certs/chaincerts/csr will be stored under below location, you can refer those if you intend to apply those using cpanel GUI manually
~/.acme.sh/yourdomain.com/
5) Apply Cert to website using cPanel hook
acme.sh --deploy --deploy-hook cpanel_uapi --domain yourdomain.com
6) In CPanel, redirect your domain to use HTTPS. If CPanel is greyed out, simply use an HTACCESS modification.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
Credit: Anuj Singh Tomar
Here is a handy BASH script that will automate this process for you. NOTE: This bash script assumes you’re using standard bash and the standard ‘public_html’ path that namecheap provides. Be sure to edit for your needs! (This assumes you ran the setup and are registered with LE)
#!/bin/bash
echo What is the domain (i.e. example.com)?
read domain
.achme.sh/acme.sh --issue --webroot ~/public_html -d $domain --staging --server letsencrypt &&
.achme.sh/acme.sh --issue --webroot ~/public_html -d $domain --force --server letsencrypt &&
.achme.sh/acme.sh --deploy --deploy-hook cpanel_uapi --domain $domain
instructional
]
Other posts:
- Let's Encrypt on Shared Hosting (namecheap) - 05/03/2022
- 1967 Ford Mustang: Burnout Compilation - 02/11/2022
- Fujitsu ScanSnap S510 - How To Install On MacOS Monterey v12+ - 01/04/2022
- JetSki - The Broadkill River (Lewes to Milton) - 12/11/2021
- Drupal 8: End of Life - 12/03/2021
- Mustang Update - 11/06/2021
- New Release: Feel It - 11/05/2021
- How To Setup Docksal/Docker On A Remote Ubuntu Desktop - 11/01/2021
- SOLVED: Docker Desktop - Windows/Ubuntu App/WSL - "Page cannot be reached" - 10/29/2021
- Optimize Drupal for Local Development - 10/13/2021
- VS Code Virtualized In Browser On Remote Server - 10/13/2021
- Drupal 8: How To Setup Two-Factor Authentication - 09/03/2021
- Composer: How to require an alpha/beta - 08/25/2021
- 2017 Yamaha FX SVHO: Spark Plug Change - 06/15/2021
- Helpful Links - 06/09/2021
- WinSCP: How to change password after login - 06/08/2021
- Mustang Update: Ride Height Set - 06/03/2021
- Mustang Update: Rear Suspension Being Installed - 05/31/2021
- Mustang Update: All metal work is done - 03/01/2021
- GitLab: How to fork you own repository - 02/26/2021
- Mustang Update - 11/25/2020
- How to install MCRYPT on UBUNTU with PHP Version 7.3 - 10/01/2020
- Mustang Update: The 67 is at the performance shop - 09/16/2020
- NEW: Karma Flight Playlist Added! - 09/02/2020
- 2004 Crown Victoria: LED hyper-flash fixed with resistor install - 08/26/2020
- The Broadkill River - 08/17/2020
- The Lower Loop - 08/09/2020
- Went for a bike ride at lunch - 08/06/2020
- The Storm: Hurricane Isaias - 08/05/2020
- Dumb Dog - 08/05/2020
- The Upper Loop - 07/20/2020
- SOLVED: Composer Update/Install Not Working While Updating From Drupal 8.8.5 to 8.8.6 - 05/24/2020
- Domain Registrar Review - 04/16/2020
- Drupal 8 Config and Git - 02/21/2020
- SOLVED: Compass Install Issues – Ubuntu - 11/17/2019
- SOLVED: Lando and Composer Problem - 10/07/2019
- Thunder Over Dover - 09/19/2019
- Happy IT Professionals Day! - 09/17/2019
- Crossing the Delaware Bay on a WaveRunner/Jet Ski - 09/02/2019
- The Epoxy Stump Table - 07/01/2019
- Water Leak With Mini-Split - 03/08/2019
- Drupal 7 Base Environment on Docker Hub - 03/08/2019
- Try - 02/25/2019
- Migration from Drupal 7 to Drupal 8 - 02/13/2019
- XPath Cheatsheet - 01/31/2019
- The blog is live! - 01/29/2019