GeekFolks

How to Auto-Renew SSL Certificates on cPanel with acme.sh

Md Nasir WahidMd Nasir Wahid
Updated August 19, 20262 min readSoftware delivery and engineering practice
SSl

Let's Encrypt certificates expire every 90 days. Manual renewal is tedious and error-prone — missing a renewal means expired certificates, browser warnings, and potential site downtime. Automation eliminates human error entirely.

What You'll Need

  • SSH access to your cPanel account (root privileges not required)
  • acme.sh installed in your home directory
  • A domain with a working webroot for HTTP validation

Step 1: Install acme.sh (If Not Already Installed)

Check if already installed:

shell
ls -la ~/.acme.sh/acme.sh

If not present, install via:

shell
curl https://get.acme.sh | sh -s email=your-email@example.com

This installs to ~/.acme.sh without requiring root access.

Step 2: Write the Issue + Deploy Script

The process involves two stages: issuing the certificate (via Let's Encrypt validation) and deploying it to cPanel using the cpanel_uapi hook.

Here's the complete script:

renew_ssl_cpanel.sh
#!/bin/bash## renew_ssl_cpanel.sh# Issues/renews a Let's Encrypt cert via acme.sh and auto-installs it into cPanel# via the built-in cpanel_uapi deploy hook.## Run as the cPanel account user that owns the domain — no root needed.set -euo pipefail # ---- CONFIG: edit these for your domain ----DOMAIN="yourdomain.com"ALIAS="www.yourdomain.com"WEBROOT="/home/youruser/yourdomain.com"ACME_SH="$HOME/.acme.sh/acme.sh"LOGDIR="$HOME/logs"mkdir -p "$LOGDIR"LOGFILE="$LOGDIR/acme_cpanel_deploy.log" echo "===== $(date) : Starting cert issue/renew for $DOMAIN =====" >> "$LOGFILE" # 1. Issue (or renew) the certificateif "$ACME_SH" --issue -d "$DOMAIN" -d "$ALIAS" -w "$WEBROOT" --server letsencrypt >> "$LOGFILE" 2>&1; then    echo "Cert issued OK for $DOMAIN" >> "$LOGFILE"else    echo "Cert issuance FAILED for $DOMAIN - aborting deploy" >> "$LOGFILE"    exit 1fi # 2. Deploy into cPanel via UAPIif "$ACME_SH" --deploy -d "$DOMAIN" --deploy-hook cpanel_uapi >> "$LOGFILE" 2>&1; then    echo "Cert deployed OK into cPanel for $DOMAIN" >> "$LOGFILE"else    echo "Deploy FAILED for $DOMAIN" >> "$LOGFILE"    exit 1fi echo "===== $(date) : Done for $DOMAIN =====" >> "$LOGFILE"

Save as ~/scripts/renew_ssl.sh and make executable:

shell
chmod +x ~/scripts/renew_ssl.sh

Important: the --force flag is omitted deliberately. Without it, acme.sh only reissues certificates nearing expiry — preventing unnecessary rate limit hits across multiple domains.

Step 3: Test It Manually First

Run the script manually and check the log:

shell
~/scripts/renew_ssl.shtail -f ~/logs/acme_cpanel_deploy.log

For debugging, use:

shell
bash -x ~/scripts/renew_ssl.sh

This reveals command-by-command execution, typically exposing webroot path issues or domain/account mismatches.

Step 4: Schedule It with Cron

Once tested successfully, add to crontab:

shell
crontab -e

Insert:

plaintext
15 3 * * 0 /home/youruser/scripts/renew_ssl.sh >> /home/youruser/logs/cron_run.log 2>&1

This runs weekly on Sundays at 3:15 AM. Since acme.sh auto-renews around day 60 of the 90-day cycle, weekly checks provide ample buffer with redundancy for transient failures.

How the Deploy Hook Actually Works

The cpanel_uapi deploy hook invokes cPanel's UAPI (SSL::install_ssl) directly. When run as the domain-owning cPanel user (not root), no additional permissions are required — cPanel inherently trusts the account to manage its own certificates.

Wrapping Up

With this setup, the entire SSL lifecycle runs unattended weekly. Certificates issue, validate, and install automatically. The only ongoing maintenance is occasional log review or implementing log rotation.

No more calendar reminders. No more manual WHM logins. Just a cert that renews itself, quietly, in the background.

Where this fits into a bigger picture

Certificate renewal is one small piece of the production hardening we build into every custom software engagement — the unglamorous automation that keeps a system reliable long after launch. If your team is stretched thin on this kind of operational work, that's often a sign it's time for dedicated developers rather than another one-off fix.

For more on the platform side of production reliability, see The Retrieval Loop and Plug-and-Play Payments in Laravel for two other engineering-practice writeups.

ShareLinkedInX

Get new posts in your inbox

No spam — just new articles as we publish them.

Md Nasir Wahid

Md Nasir Wahid

AI-native Engineer & Consultant

Founder of GeekFolks and a full-stack developer with 5+ years of experience across PHP (Laravel, Yii2), Node.js, and Next.js — building scalable, cloud-native systems with a growing focus on AI-driven products.

View full profile →
Diagram showing a customer message routed through an agentic AI loop of goal, reason, act, and observe, branching into four real actions: search catalog, submit order with an approval gate, track shipment, and start a return with an approval gate
AI & Automation

Agentic AI for E-Commerce: What It Actually Automates

Most "AI for e-commerce" talk stops at product recommendations. Agentic AI goes further: it can search your catalog, place an order, and check a shipment status as real actions. Here's what that actually looks like, and where the guardrails have to sit.

Md Nasir Wahid3 min read
Side-by-side comparison diagram of RAG versus agentic AI: RAG follows a single read-only pass from question to retrieve to generate to answer, while agentic AI loops through goal, reason and act, and observe until the task is completed
AI & Automation

RAG vs Agentic AI

RAG answers questions from your data. Agentic AI takes multi-step action using it. Here's how to tell which one your business needs, when you need both, and why getting this wrong is the most common way AI budgets get wasted.

Md Nasir Wahid3 min read
Diagram of the agentic AI loop: goal, reason and plan, act by calling a tool, observe the result, then either loop back to reasoning or finish once the goal is met
AI & Automation

How Agentic AI Actually Works

A chatbot answers questions. An agent gets things done. Here's the real loop behind agentic AI — goal, reason, act, observe — traced through a live refund request, plus what it takes to build one safely for a real business.

Md Nasir Wahid4 min read