Forcing a Let's Encrypt SSL Certificate Renewal in an LNMP Environment
In LNMP (Linux, Nginx, MySQL, PHP) environments, Let's Encrypt certificates are typically managed by the acme.sh script. While automatic renewal is configured by default, you may need to force an immediate renewal before the scheduled date. This guide provides the commands and steps to do so.
Command to Force Renewal
Connect to your server via SSH and run the following command to force a renewal of all certificates managed by acme.sh:
/usr/local/acme.sh/acme.sh --cron --force --home /usr/local/acme.sh
Command Parameter Breakdown
--cron: Runs the script in cron mode, checking and renewing all configured certificates.--force: Forces an immediate renewal attempt, even if the certificate is not yet near expiry. Useful for troubleshooting or immediate updates.--home /usr/local/acme.sh: Specifies theacme.shinstallation directory. This is the default path for the LNMP one-click installation package. Adjust if your path differs.
Steps and Important Notes
- Permissions: You usually need to run this command as the
rootuser or withsudo. - Process Verification: After execution,
acme.shwill communicate with Let's Encrypt servers to validate domain ownership and issue a new certificate. A successful renewal will output a message like "Cert success." - Restart Nginx: Once the certificate files are updated (typically in
/usr/local/nginx/conf/ssl/), you must restart the Nginx service for the new certificate to take effect. Useservice nginx restartorsystemctl restart nginx. - Automatic Renewal: Under normal conditions,
acme.shis configured with a cron job to handle renewals automatically. The force command is only for special cases. - Path Confirmation: If you get a "command not found" error, verify the
acme.shinstallation path. You can search for it using:find / -name acme.sh 2>/dev/null.
Alternative Simplified Command
If acme.sh is in your system's PATH, you can use this simpler command:
acme.sh --cron --force
This uses the default configuration directory (usually ~/.acme.sh/). For LNMP one-click installs, using the full path as shown earlier is recommended for reliability.
Note: Let's Encrypt certificates are valid for 90 days. Ensure automatic renewal is set up and periodically check logs (e.g.,
/usr/local/acme.sh/acme.sh.log) to confirm the process is working.