If, after configuring the domain on our PrestaShop image, you want to secure your blog with an SSL certificate, follow the steps below.
We will install Certbot to install a free certificate from Let’s Encrypt. To complete these steps, you will need to connect via SSH to the PrestaShop server you created and configure it as explained below.
First steps
Before installing the certificate, you first need to configure the domain in PrestaShop. To do this, follow the steps in this other tutorial: Add a domain to the PrestaShop image.
First, go to the Tráfico & SEO section under Parámetros de la tienda and, when adding the domain in Prestashop, make sure you also add it in the Dominio SSL section:
Save the changes, then under Parámetros de la tienda, click Configuración to select the Activar SSL checkbox (remember to also select the checkbox for all pages once you have completed the article):
Once you save the changes, the website will stop working. You then need to connect to the server via SSH and carry out the following steps.
Manual SSL certificate installation
Install the following package to obtain certificates with Certbot:
# apt install certbot python3-certbot-nginx
Next, edit the Nginx configuration file located at /etc/nginx/sites-enabled/default
# nano /etc/nginx/sites-enabled/default
Change this:
server_name ubuntu-1804-image;
To this (adding www is optional, not required):
server_name midominio.es www.midominio.es;
Save the changes and restart the Nginx service:
# systemctl reload nginx
Finally, generate the certificate with the following command:
# certbot --authenticator webroot -w /var/www/html/prestashop/ --redirect --installer nginx -d midominio.es
If you added www, run this command:
# certbot --authenticator webroot -w /var/www/html/prestashop/ --redirect --installer nginx -d midominio.es -d www.midominio.es
Automatic SSL certificate installation
To automate the entire process, we have created a script that performs the installation with a single command. Use this script as follows:
# wget https://gitlab.com/clouding.io-tech.support/certbot-ssl-images/raw/master/prestashop-nginx-ssl.sh
# chmod u+x prestashop-nginx-ssl.sh
To generate the certificate:
# ./prestashop-nginx-ssl.sh [domain] [e-mail]
For example:
# ./prestashop-nginx-ssl.sh clouding.io no-reply@clouding.io
The email address must be active, and the domain must point to the server.