Web Development & WordPress

Install Free SSL to your domain in Hostinger VPS using terminal and SSH

Basically my client’s ssl was expired, he was using hostinger vps and i have helped him to install a new free ssl to his domain ( hosted in vps) using ssh and terminal.
Here are the steps. Just use the codes i shared step by step.

At First login to SSh

ssh root@your_ip_address

Are you sure you want to continue connecting (yes/no/[fingerprint])? yes,
Warning: Permanently added ‘IP ADDRESS” to the list of known hosts.

root@your_ip_address’s password:

Enter your SSH Password

After Entering the correct password, update the server

root@srvxxxx :~# sudo apt update

Install certbot

root@srvxxxx:~# sudo apt install certbot


Check if your server is running under nginx or apache2 ( i have checked it using the codes below, my one is running under apache2 )

root@srvxxx:~# sudo systemctl status nginx


Unit nginx.service could not be found.


root@srvxxx:~# sudo systemctl status apache2


● apache2.service – The Apache HTTP Server

*** my server is running under apache2

root@srvxxxx:~# nginx -v


Command ‘nginx’ not found, but can be installed with:

as my site is not under nginx, so it is returning nothing

root@srvxxx:~# apache2 -v


Server version: Apache/2.4.52 (Ubuntu)
Server built: 2023-05-03T20:02:51

** as my site is running apache2, so it is returning the version

root@srvxxxx:~# sudo certbot –apache


Saving debug log to /var/log/letsencrypt/letsencrypt.log
The requested apache plugin does not appear to be installed


root@srvxxxx:~# sudo apt install certbot python3-certbot-apache

Reading package lists… Done

root@srvxxxx:~# sudo certbot –apache

Saving debug log to /var/log/letsencrypt/letsencrypt.log

Which names would you like to activate HTTPS for?


1: yourdomain.com
2: http://www.yourdomain.com


Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter ‘c’ to cancel): 2
Requesting a certificate for http://www.yourdomain.com

Successfully received certificate.


root@srvxxxx:~# sudo service apache2 restart
root@srvxxxx:~# Connection to your_ip_address closed by remote host.


Connection to your_ip_address closed.


root@srvxxxx:~# sudo certbot –apache


Saving debug log to /var/log/letsencrypt/letsencrypt.log

Which names would you like to activate HTTPS for?


1: yourdomain.com
2: http://www.yourdomain.com


Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter ‘c’ to cancel): 2
Requesting a certificate for http://www.yourdomain.com

Successfully received certificate.

root@srvxxxx:~# sudo service apache2 restart

Leave a comment