Come hang with us on Discord and chat directly with the team!Discordtop-bar-close-icon

2024-09-20

How to Secure Apache with Lets Encrypt on CentOS 7

tutorials
img

To secure your Apache server with Let's Encrypt on CentOS 7, you need to install Certbot, which is not available by default in the package manager. First, enable the EPEL repository to access Certbot. You can do this by executing the following command:

sudo yum install epel-release

Once the EPEL repository is enabled, proceed to install Certbot:

sudo yum install certbot python2-certbot-apache

After installing Certbot, you can obtain an SSL certificate by running:

sudo certbot --apache

This command will automatically configure SSL for your Apache server. Certbot will prompt you to enter your email address and agree to the terms of service. It will also ask if you want to redirect all HTTP traffic to HTTPS, which is recommended for enhanced security.

To ensure your SSL certificate is renewed automatically, set up a cron job. Open the crontab editor:

sudo crontab -e

Add the following line to schedule a renewal check twice a day:

0 */12 * * * /usr/bin/certbot renew --quiet

This setup will help maintain your website's security by keeping your SSL certificates up to date without manual intervention.