
If you have a website, you’ve probably considered it necessary at some point Install an SSL certificateIn this way, when accessing the page, the protocol is changed from https:// to https://, so that people who access it do not get the «Connection is not secure» warning.
However, if your website is installed on an Apache server and you have not been able to install the certificate, you have come to the right place because today we will show you how to install an SSL certificate on one of these servers.
Step 1: Get the necessary files
To properly install a certificate, you need three files: the certificate itself, which must be in .crt format, the private key for access after installation, which is in .key format, and last but not least, the certificate authority that provides that the certificate belongs to a valid company, this file comes in .ca format.
Step 2: Copy the files to the server and access the certificate directory
To do this, it is recommended to upload files using the FTP file transfer protocol, which allows secure uploading of documents. Later, connect to the server using Secure Shell (SSH). This can be accomplished through a computer indexed directly to the server or through a router.
Later, use the command cd /etc/apache2/ssl/ to enter the directory where the certificates are stored.
Step 3: Create a certificate directory corresponding to your domain
To create your domain directory you need to use the mkdir command followed by the domain name, cd and then the name again, the result should be something like «mkdir urladdress.com cd urladdress.com».
Step 4: Move the files to the directory and change the owner and group to root
To move previously uploaded files to a directory via FTP, you must use the following commands:
mv /var/www/minuevaweb.es/datos/web/certificado.crt /etc/apache2/ssl/minuevaweb.es/
mv /var/www/minuevaweb.es/datos/web/certificado.key /etc/apache2/ssl/minuevaweb.es/
mv /var/www/minuevaweb.es/datos/web/certificado.ca /etc/apache2/ssl/minuevaweb.es/
To subsequently change the owner and group to root, enter these commands:
chown root:root /etc/apache2/ssl/minuevaweb.es/certificado.crt
chown root:root /etc/apache2/ssl/minuevaweb.es/certificado.key
chown root:root /etc/apache2/ssl/minuevaweb.es/certificado.ca
Step 5: Configure the VirtualHost block on the Apache server
For this part you need to access the VHost configuration files directory via cd /etc/apache2/sites-enabled/ command, then you need to edit the web settings file where you will install the certificate It is recommended to use a text editor like to use nano.
Duplicate the virtualhost block, in the lower block change the port number from 80 to 443 with the command then add the lines corresponding to the certificate paths before the end, so the complete file should look like this:
Server name minuevaweb.es
Server alias www.minuevaweb.es
DocumentRoot «/var/www/minuevaweb.es/datos/web»
CustomLog /var/www/minuevaweb.es/logs/20190307.log often
Error log /var/www/minuevaweb.es/logs/error_20190307.log
Server name minuevaweb.es
Server alias www.minuevaweb.es
DocumentRoot «/var/www/minuevaweb.es/datos/web»
CustomLog /var/www/minuevaweb.es/logs/20190307.log often
Error log /var/www/minuevaweb.es/logs/error_20190307.log
SSL mechanism enabled
SSLCertificateFile /etc/apache2/ssl/minuevaweb.es/certificado.crt
SSLCertificateKeyFile /etc/apache2/ssl/minuevaweb.es/certificado.key
SSLCACertificateFile /etc/apache2/ssl/minuevaweb.es/certificado.ca
Finally, save the changes, verify that the configuration is correct, and reload the Apache configuration to apply the changes. After that, the certificates should be installed on your end.