How to install lets encrypt ssl certificate on aws ec2 linux instance with apache server



I decided to remove load balancer as i was incurring significant charges because of it , the problem propped up as I was getting free ssl certificate through aws certificate manager.

As soon as I removed load balancer and changed the routing polices , my website was no longer encrypted with ssl. To solve it I decided to install lets encrypt ssl certificate using certbot , this article will discuss how to do the same in easy steps :

1) Open your command prompt or terminal and ssh into your aws instance 

2) I have decided to use pip for installing it, 

3) Create a virtual environment named certbot 
virtualenv ~/.certbot
source ~/.certbot/bin/activate
4) Finally install certbot :
pip install certbot
5) After installing create certificate for your website using the below command 
sudo ~/.certbot/bin/certbot certonly --webroot -w /var/www/html -d www.yourlocale.in -d yourlocale.in
Replace with your own website domain 
This will ask few questions , agree to the terms and provide the email address and finally your certificate will be generated showing the path of the key and certificate , keep a note of this as we will use this.
6) Our next Step is to enable TLS on the server this can be easily done using the below command:
sudo yum install -y mod24_ssl
This will create a ssl configuration file named ssl.conf in httpd folder inside config.d folder our next task is to edit this file
7) To edit file assuming you are in root directory
sudo vi /etc/httpd/conf.d/ssl.conf
press i
and find certificate and key path , replace it with the one you earlier noted down 
press esc and :wq to save and quit the file
8) Finally restart the apache server
sudo service httpd restart
9)You must be sure that in your instance security group you are listening to port 432 and allowing request from all ips.
Finally you have completed all the steps and your website supports secure connection, once the certificate expire usually in 3 months we can simply renew it using the following command 
sudo ~/.certbot/bin/certbot renew
Thank You , feel free to reach out in case of any difficulties.


Comments

Popular posts from this blog

Autonomous bot using Augmented Reality

Dream 11 Csk vs Kkr