Install free SSL by using certbot for ubuntu apache
With this method, you can make your domain HTTPS for free on any ubuntu server like digital ocean, AWS, Linode, etc
You can get a $100 bonus for 2 months using my referral on digital ocean droplet, it’s worth trying cloud hosting for 2 months
Click here for bonus
- SSH into the server, using the command
ssh root@ip_address
2. Type these commands
sudo snap install core; sudo snap refresh core
3. Remove any Certbot OS packages( if present)
sudo apt-get remove certbot
4. Install Certbot
sudo snap install --classic certbotsudo ln -s /snap/bin/certbot /usr/bin/certbotsudo a2enmod sslsystemctl restart apache2
5. You need to add a domain to the droplet or instance. Make sure you changed nameservers of the domain pointing to the digital ocean or aws
After this, you need to modify apache settings
Previous settings look like this
You need to change it to:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
Alias /static /myproject/code_folder/static <Directory /myproject/code_folder/static>
Require all granted
</Directory> <Directory /myproject/code_folder/wsgi_folder>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>WSGIDaemonProcess myproject python-home=/myproject/venv python-path=/myproject/code_folderWSGIProcessGroup myprojectWSGIScriptAlias / /myproject/code_folder/wsgi_folder/wsgi.py
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined<VirtualHost *:443>
ServerAdmin webmaster@localhost
Alias /static /myproject/code_folder/static<Directory /myproject/code_folder/static>
Require all granted
</Directory><Directory /myproject/code_folder/wsgi_folder>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
6. Restart your server
systemctl restart apache2
7. Get and install your certificates.
sudo certbot --apache
Enter your email address and domain like
example.com www.example.com
You will see a success message like
8. Test automatic renewal
sudo certbot renew --dry-run
Your website should now work with HTTPS.