Notes

Enable SSL in OpenCart

Edit on GitHub

OpenCart
2 minutes
  • Install SSL
  • Enable SSL in Admin
  • Edit config.php files

Install SSL

On an Apache (Ubuntu) system where you have SSH access, you can run the following commands to install an SSL (Let’s Encrypt)

1sudo apt-get update
2sudo apt-get install software-properties-common
3sudo add-apt-repository ppa:certbot/certbot # add certbot repo
4sudo apt-get update
5sudo apt-get install python-certbot-apache # install certbot
6sudo certbot --apache # run certbot

Don’t forget to add certbot renew to cron

1sudo crontab -e
2# @daily certbot renew # Check SSL certificates for renewal

Enable SSL in Admin

Admin > System > Settings (Edit) > Server > Use SSL (Yes) > Save

Edit config files

Edit config.php

1// HTTPS
2define('HTTPS_SERVER', 'https://yourdomain.com/');

Edit admin/config.php

1// HTTPS
2define('HTTPS_SERVER', 'https://yourdomain.com/admin/');
3define('HTTPS_CATALOG', 'https://yourdomain.com/');

Troubleshooting

If you forgot to edit the system settings, and are now unable to login at the Admin login page, you’ll have to edit the setting in the database via PHPMyAdmin

Open your OpenCart database (find out from config.php if you’re not sure which one it is) and go to the oc_settings table, run the following SQL query

1UPDATE `oc_setting` SET `value` = '1' WHERE `key`='config_secure'

  • Site looks broken, getting the following error in console
Failed to load resource: net::ERR_INSECURE_RESPONSE

This can happen when you have transferred the site to a new server/domain and SSL is not installed on the new server/domain. Installing an SSL will fix the issue.