Securing your website with SSL/TLS encrypts the data transferred between your server and users, providing a secure connection and improving your site's trustworthiness. This guide will walk you through the process of setting up SSL/TLS on your Apache web server using Certbot.
You need Apache installed and running on your server, and a domain name pointing to your server's IP address. You'll also need root or sudo privileges to install software and make configuration changes.
Certbot is a tool that automates the process of obtaining and installing SSL certificates from Let's Encrypt. Install Certbot and the Apache plugin with the following commands:
sudo apt update
sudo apt install certbot python3-certbot-apache
With Certbot installed, you can now obtain an SSL certificate by running:
sudo certbot --apache
Follow the prompts to enter your email address and agree to the terms of service. Certbot will automatically configure SSL/TLS for your Apache server.
Certbot will modify your Apache configuration to enable SSL/TLS. You can verify the configuration by checking the virtual host file:
sudo nano /etc/apache2/sites-available/yourdomain-le-ssl.conf
Ensure the file includes the following directives:
<VirtualHost *:443>
ServerAdmin webmaster@yourdomain
ServerName yourdomain
DocumentRoot /var/www/yourdomain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/yourdomain/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/yourdomain/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/yourdomain/chain.pem
</VirtualHost>
Save and close the file, then reload Apache to apply the changes:
sudo systemctl reload apache2
Your website should now be secured with SSL/TLS, providing a secure connection for your users. You can test the SSL configuration using online tools like SSL Labs' SSL Test to ensure everything is set up correctly.