How to Install Let’s Encrypt Free SSL on NameCheap Shared Hosting

·

Last year, I heard about Let’s Encrypts free SSL. However, I was using WordPress.com to host my website. So, I already had SSL on my site. So, I did not pay much attention to it.

Since 2017, I have been entirely serious about my site and plan to write regularly on my blog. I have a “bad reputation” for developing a new idea every morning. So yesterday, I installed the free SSL certificate on my shared hosting and saved 10 USD!

So here’s how I did it.

  1. Searched for “Free SSL” on Google. (I forgot the name Let’s Encrypt).
  2. Then I found a couple of organizations, and “Let’s Encrypt” clicked in my head! Because my boss mentioned this name earlier.
  3. Then I searched “Let’s encrypt on a shared hosting” again and opened another tab to check if NameCheap has any built-in support for Let’s Encrypt. So I searched again.
  4. Then I found this article: How To Install Free SSL From Let’s Encrypt On Shared Hosting.
  5. I opened up the terminal on my MacBook and wrote
    ssh -p 21098 myUserName@sekander.pro
    Here  -p 20198 is the port number for shell access. I got the port number from NameCheap’s Support doc.
  6. Then, I used my cPanel password as the shell password.

    But the terminal told me I do not have shell access enabled on my hosting. So, I contacted NameCheap support via live chat.

  7. So I logged in again and ran the commands following commands
git clone https://github.com/kelunik/acme-client
cd acme-client php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"; php composer-setup.php; php -r "unlink('composer-setup.php');"; php composer.phar install --no-dev
php bin/acme setup --server letsencrypt --email your@email.com
php bin/acme issue --domains yourdomain.com:www.youdomain.com --path /home/x123011738/public_html:/home/x123011738/public_html --server letsencrypt
cd /home/x123011738/acme-client/data/certs/acme-v01.api.letsencrypt.org.directory/yourdomain.com

Then, I copied the contents of the fullchain and key file using the commands below and saved them on my desktop with the same name.

cat fullchain.pem
cat key.pem

Then, I logged into the cPanel of my site and found the option to manage SSL Certificates. I selected the domain and uploaded the files I had made on my desktop. If your site has static HTML files, then you’re done here. But mine is a WordPress-powered site. So, I had to change the URL structure from wp-admin → Settings → General. I have changed http://sekander.pro to https://sekanderb.com and then saved the settings.

But I was not happy yet. Because I found the SSL certificate on the single posts and pages, but it was not working on the homepage.

So I had to google “Setup SSL WordPress” again and found that I needed to paste something in my .htaccess file!

I logged in to the cPanel again, and good lord! There’s no .htacess file on the hosting root! How’s this possible? How can a WordPress site run without a .htacess file?

Then my colleague, who luckily works on the Dokan plugin support team, told me it could be hidden. So I enabled showing hidden files, and voila! The file had hefty lines of rewrite rules and allowed file types to upload.

I pasted the following lines at the very end of the .htacess file

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [R,L]
</IfModule>

This article has more detailed information: How to Add SSL and HTTPS in WordPress

It helped me to redirect the traffic with HTTP to redirect to https. So now I can see the green https on the home page.

I have set up a cron job to renew the SSL certificate monthly.

This is all I have done to activate SSL on this site. If you get confused or need any clarification from me, feel free to comment below 🙂

Comments

6 responses to “How to Install Let’s Encrypt Free SSL on NameCheap Shared Hosting”

  1. rubel Avatar

    when run this [1] command then showing this [2] error

    1. php -r “copy(‘https://getcomposer.org/installer’, ‘composer-setup.php’);”; php composer-setup.php; php -r “unlink(‘composer-setup.php’);”; php composer.phar install –no-dev

    2. Some settings on your machine make Composer unable to work properly.
    Make sure that you fix the issues listed below and run this script again: ‘composer-setup.php’);”; php composer-s
    The suhosin.executor.include.whitelist setting is incorrect.
    Add the following to the end of your `php.ini` or suhosin.ini (Example path [for Debian]: /etc/php5/cli/conf.d/suhosin.ini):
    suhosin.executor.include.whitelist = phar

    The php.ini used by your command-line PHP is: /opt/alt/php56/etc/php.ini
    If you can not modify the ini file, you can also run `php -d option=value` to modify ini values on the fly. You can use -d multiple times.

    Could not open input file: composer.phar

    1. Sekander Avatar

      Hello Rubel,

      Sorry to know that you’re having issues installing SSL on your site. I would request you to look at the error message carefully.

      It is telling that a setting in your php.ini file is not correct to run the files with .phar extension. It is also mentioned that which setting needs to be configured.

      If you are unable to do the changes, please contact your hosting provider for assistance.

    1. Sekander Avatar

      Hey Steve,
      I have copy pasted the renew command to the cron option of my cPanel but it does not help. Because each time a new certificate is generated, I need to copy paste the keychain to the SSL section of the cPanel.

      However, the cron job fails everytime!

      I go through the entire process when I need to renew.

    1. Sekander Avatar

      Hello Waseem,
      There could be several reasons for the error message. Please double check if you are on the right location and everything is up to date

      I have been following this process for more than a year and I never found such conflict. I removed the error message for security reasons. It was showing your cPanel username!

Leave a Reply