keepcalculator

06 Numbers and Powers

Enable HTTPS on PrestaShop with Let’s Encrypt on a VPS

Card No. 06·41431 · Updated · Standard formula, shown below

This guide walks you through securing your PrestaShop store with a free SSL/TLS certificate from Let’s Encrypt on a VPS (Virtual Private Server). You’ll get the green padlock in browsers, encrypted customer data, and improved search rankings. We’ll cover installing Certbot, obtaining the certificate, configuring PrestaShop to use HTTPS, and setting up automatic renewal.

What You’ll Need

  • A VPS running a Linux distribution (Ubuntu, Debian, CentOS, etc.) with root or sudo access.
  • A domain name pointing to your VPS’s public IP address (A record).
  • PrestaShop installed and accessible via HTTP (port 80).
  • SSH client (like PuTTY on Windows or Terminal on macOS/Linux) to connect to your server.

Step-by-Step

  1. Connect to your VPS via SSH. Open your terminal and run: ssh user@your-server-ip. Replace ‘user’ with your username and ‘your-server-ip’ with your server’s IP address.
  2. Update your system packages. Run sudo apt update && sudo apt upgrade -y (for Debian/Ubuntu) or sudo yum update -y (for CentOS/RHEL). This ensures you have the latest security patches.
  3. Install Certbot and the Apache or Nginx plugin. The plugin depends on your web server. For Apache: sudo apt install certbot python3-certbot-apache. For Nginx: sudo apt install certbot python3-certbot-nginx. On CentOS, use sudo yum install certbot python3-certbot-apache or python3-certbot-nginx.
  4. Stop your web server temporarily (optional but recommended). Some setups may have port 80 occupied. Run sudo systemctl stop apache2 or sudo systemctl stop nginx to free the port, then start it again after the certificate is issued.
  5. Run Certbot to obtain the certificate. Execute sudo certbot --apache or sudo certbot --nginx. Follow the interactive prompts: enter your email address, agree to the terms of service, and select the domain name(s) you want to secure. Certbot will automatically configure your web server to use the certificate.
  6. Test the certificate. Visit https://yourdomain.com in your browser. You should see a padlock icon and no security warnings. If you get a warning, check the certificate details and ensure the domain matches.
  7. Configure PrestaShop to use HTTPS. Log into your PrestaShop admin panel. Go to Shop Parameters > General. Under the ‘Maintenance’ section, set ‘Enable SSL’ to Yes. Also set ‘Enable SSL on all pages’ to Yes to force HTTPS across the entire store.
  8. Update your shop URL. In the same General settings page, change the ‘Shop URL’ fields to use https:// instead of http://. Also update the ‘Base URI’ if necessary.
  9. Clear PrestaShop cache. Go to Advanced Parameters > Performance and click ‘Clear cache’. This prevents old HTTP links from lingering.
  10. Set up automatic renewal. Let’s Encrypt certificates last 90 days. Certbot can renew them automatically. Test the renewal process with sudo certbot renew --dry-run. If it works, add a cron job to run certbot renew twice daily. For example, edit crontab with sudo crontab -e and add: 0 0,12 * * * certbot renew --quiet.

Common Mistakes

  • Forgetting to update PrestaShop URLs. Even if the certificate works, internal links may still use HTTP, causing mixed content warnings. Always update the shop URL and enable SSL in PrestaShop.
  • Not opening port 443. Your VPS firewall must allow HTTPS traffic. Use sudo ufw allow 443/tcp (if using UFW) or check your cloud provider’s security group settings.
  • Using the wrong domain. Certbot will fail if the domain doesn’t point to your server’s IP. Verify DNS records before running Certbot.
  • Ignoring mixed content. After enabling SSL, some resources (images, scripts) might still load over HTTP. Use a browser console to find and fix these.

Tips

  • Use a wildcard certificate if you have multiple subdomains (e.g., shop.example.com, api.example.com). Run sudo certbot --apache -d *.example.com -d example.com with DNS-01 challenge.
  • Backup your configuration before making changes. PrestaShop and web server configs are critical.
  • Monitor renewal. Set up email alerts or use a monitoring service to ensure your certificate renews successfully.
  • Consider HTTP to HTTPS redirect. Certbot usually adds this automatically. If not, add a 301 redirect in your server config to avoid duplicate content.

Troubleshooting

  • Certbot fails with ‘Invalid response from http://…’ This usually means port 80 isn’t accessible or the domain doesn’t point to your server. Check your firewall and DNS.
  • Certificate issued but browser shows warning. Ensure the certificate is for the exact domain you’re visiting (including ‘www’ if applicable). Also check that your server’s time is correct.
  • PrestaShop admin panel becomes inaccessible after enabling SSL. This can happen if the certificate isn’t valid. Temporarily disable SSL by editing config/settings.inc.php and setting _PS_SSL_ENABLED_ to ‘0’. Then fix the certificate issue.
  • Mixed content warnings persist. Use the ‘Better Search Replace’ plugin or manually update database URLs. Or use a PrestaShop module like ‘Force HTTPS’ to handle redirects.
  • Renewal fails. Check the Certbot logs at /var/log/letsencrypt/letsencrypt.log. Common issues include port 80 being blocked or domain verification failing.

Frequently Asked Questions

Do I need to buy an SSL certificate?

No, Let’s Encrypt provides free certificates that are trusted by all major browsers. They are valid for 90 days and auto-renew.

Will HTTPS affect my PrestaShop performance?

HTTPS adds a small overhead due to encryption, but with modern hardware and HTTP/2, the impact is minimal. You can enable caching and use a CDN to mitigate.

How do I force HTTPS on all pages?

In PrestaShop, go to Shop Parameters > General and set ‘Enable SSL on all pages’ to Yes. Also ensure your server redirects HTTP to HTTPS.

Can I use Let’s Encrypt on a shared hosting plan?

This guide is for VPS. For shared hosting, check if your provider offers Let’s Encrypt integration in the control panel (like cPanel).

What if I have multiple domains on my VPS?

Certbot can issue certificates for multiple domains in one command: sudo certbot --apache -d example.com -d www.example.com -d other.com. You’ll need to select all of them during setup.

Is it safe to run Certbot automatically?

Yes, Certbot is widely used and maintained by the Electronic Frontier Foundation. Automatic renewal is safe and recommended.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →