Namecheap Shared Hosting + LetsEncrypt
Let’s put it all on the table – Namecheap Shared Hosting does not provide built-in support for LetsEncrypt (see comment section) but you can use LE certs with a little bit of work. So if you have this type of Namecheap service, are comfortable with bash command line, looking for a LE cert, and can spare 10 minutes continue reading….
Pre-requisites
Namecheap shared hosting website
Website name is resolved by public DNS
SSH is enabled for your Namecheap VPS site
Access to your site’s cPanel console
Spare CentOS 7 system to run certbot (referred to as management server below)
Putty used for SSH sessions
Setup
- SSH to Namecheap VPS
- mkdir –p ~/www/.well-known/acme-challenge
- Check that each folder has 755 permissions and change if needed
- This location is used later for LE verification purposes
- If your site currently redirects to HTTPS edit .htaccess with vi ~/www/.htaccess
- Add RewriteCond %{REQUEST_URI} !^/.well-known below RewriteEngine On statement
- SSH to management server
- yum -y update
- yum -y install epel-release
- yum -y install certbot
- From management server run certbot certonly –manual -d yourdomain.com -m mailcontact@yourdomain.com
- Accept IP logging
- Right-click top left of putty window > Copy all to clipboard > paste to notepad
- Look for the section that contains “Make sure your web server displays the following content at” and copy text after .well-known/acme-challenge/
- Return to your VPS SSH session and create new folder based on text copied from step 5.3
- Chmod 755 the new directory
- Go back to your notepad scratch file and copy the longer string displayed below new folder path
- That data will need to be piped into an index.html file under the folder created in step 6
- Echo longstring > ~/www/.well-known/acme-challenge/newfolder/index.html
- Chmod 744 the new index.html file
- Verify the new index.html page can be reached over port 80
- Use Incognito, InPrivate, Private windows to test http://yourdomin.com/.well-known/acme-challenge/index.html
- Return to management server, the certbot session should still be live and hit enter to complete verification
- If everything went as planned you will have a new cert in /etc/letsencrypt/live/yourdomain.com
- cat /etc/letsencrypt/live/yourdomain.com/cert.pem and copy file content
- Log into cPanel console
- SSL/TLS > Upload new certificate > paste in content from Step 9.2 > save certificate
- SSL/TLS > Manage SSL Hosts > Browse Certificates > Use Certificate > Install Certificate
- Associate new cert with your website
- On management server cat /etc/letsencrypt/live/domain/privkey.pem and copy content
- Paste content from Step 11 to cPanel console private key input box
- Select Install Certificate
- Return to VPS SSH session and delete the folder you created under .well-known/acme-challenge
Certificate Renewal
- From management server run crontab -e
- Add 0 0 * * sun certbot renew –manual
- run LE cert renewal every sunday at 12am
the cert should renew on the management server when < 30 days remain on LE certificate.- TBD if this actually works for renewal. Check back summer 2017
- 6/4/2017 Update – the manual renew method will error out due to validation check. It looks like Dehydrated with a custom DNS hook is the best bet for automated renewel. I may circle back to this in the future but for now I manually renewed the cert using the process above.
- You will have to manually copy cert key back through cPanel console until LE is completely supported by Namecheap