In this tutorial, you will learn how to set up SSL/TLS certificates with the help of Certbot on an Apache web server running on Ubuntu. SSL certificates are essential for securing communication between your server and clients, protecting sensitive data from eavesdropping and ensuring a safe browsing experience for your users.
We will use Certbot, a free and open-source tool, to obtain and automatically renew SSL certificates from Let's Encrypt, a certificate authority that provides trusted SSL certificates at no cost.
The tutorial assumes you have a basic understanding of the Ubuntu command line and have already set up an Apache web server. If you haven't installed Apache yet, you can do so using apt
:
sudo apt update
sudo apt install apache2
Before proceeding, ensure that you have the following:
Certbot is available in the default Ubuntu repositories, making installation straightforward. Open a terminal and run the following commands to install Certbot:
sudo apt update
sudo apt install certbot python3-certbot-apache
Before obtaining SSL certificates, we need to configure Apache to use SSL. The Certbot tool can automatically configure Apache for us. Run the following command and follow the prompts:
sudo certbot --apache
Certbot will ask for your email address for urgent renewal and security notices. After providing it, Certbot will detect the domains configured in your Apache virtual hosts and ask you to choose which domains you want to enable SSL for. Select the appropriate domains, and Certbot will configure Apache accordingly.
Once the SSL configuration is complete, Certbot will reload Apache to apply the changes. It will also create a cron job to automatically renew the certificates before they expire.
To verify the SSL configuration, open a web browser and enter your domain with https:// (e.g., https://yourdomain.com). If everything is set up correctly, you should see a padlock icon in the browser's address bar, indicating that the connection is secure.
Certbot certificates are typically valid for 90 days and will need to be renewed periodically. The cron job created by Certbot takes care of automatic renewal. However, it's a good idea to test the renewal process manually to ensure it works as expected.
To test the renewal, run the following command:
sudo certbot renew --dry-run
Congratulations! You have successfully set up SSL/TLS certificates on your Apache web server using Certbot. Your website is now secured with encrypted communication, and users can browse it safely.
Remember to periodically check for certificate expiration and ensure that automatic renewal is working correctly to maintain a secure website.
Copyright (c) 2021 netcup
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
By making a contribution to this project, I certify that:
The contribution was created in whole or in part by me and I have the right to submit it under the license indicated in the file; or
The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same license (unless I am permitted to submit under a different license), as indicated in the file; or
The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.
I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the license(s) involved.