1 |
sudo apt install python-certbot-apache |
Then create the virtual file for your domain
1 |
sudo nano /etc/apache2/sites-available/your_domain.conf |
1 2 3 4 5 6 7 8 |
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName <span class="highlight">your_domain</span> ServerAlias <span class="highlight">www.your_domain</span> DocumentRoot /var/www/<span class="highlight">your_domain</span> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> |
Test apache configurations if they are ok
1 |
sudo apache2ctl configtest |
If ok restart apache
1 |
sudo systemctl reload apache2 |
If not check the error and correct it
Now lets generate the certificate using the carbot we just installed from the beginning of this tutorial
1 |
sudo certbot --apache -d your_domain -d www.your_domain |
This runs certbot
with the --apache
plugin, using -d
to specify the names you’d like the certificate to be valid for.
If this is your first time running certbot
, you will be prompted to enter an email address and agree to the terms of service. After doing so, certbot
will communicate with the Let’s Encrypt server, then run a challenge to verify that you control the domain you’re requesting a certificate for.
If that’s successful, certbot
will ask how you’d like to configure your HTTPS settings:
After finishing successfully, you need nothing to do extra but just to access your site on https to test if the configurations were done ok
you can use the below command to renew the certificate and if possible add it to cron so it checks and runs for automatic renewals
1 |
sudo certbot renew |
Try a dry renewal to see if renewals is done successfully on the sport before certificate expires
1 |
sudo certbot renew --dry-run |
Hope you enjoy the tutorial