Less bothering way to use Let’s encrypt certificate on Shared Hosting

After writing last article, I found a way to semi-automate it.

Required

  1. Shared hosting, that provides git, and php with at least version 5.6 (If yours doesn’t provide git, you need to directly access github page and download in zip format.)
  2. CPanel access to your hosting

Procedure

  1. Access to your server with ssh.
  2. Clone acme-client for php, and go into it.

    git clone https://github.com/kelunik/acme-client
    cd acme-client

  3. Install composer. If there’re any error related to version, change ‘php‘s into other version of phps(like php56, php70).

    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

  4. Write script

    cd ~
    nano autoscript.sh
    (Belows are scripts to write in nano)
    #!/bin/bash
    cd /home/naraeons/acme-client/
    php bin/acme setup –server letsencrypt –email (Your email)
    php
    bin/acme issue –domains (Your domains) –path (path to public_html) –server letsencrypt
    (Save and exit)
    chmod +x autoscript.sh

  5. Run autoscript.sh, and write down where does the script save your new certs. In my case, line with red underline shows my path.
  6. Access CPanel, and push Cron Jobs in Advanced.
  7. Set as below, and press Add New Cron Job.
  8. When you need to refresh your certs, go and get your new certs at path you wrote down in Step 5. Press here and do the rest from step 7.

Leave a Reply

Your email address will not be published. Required fields are marked *