Logo

How to Install Let's Encrypt SSL in Apache on CentOS 7

Apr 04, 2024

To install Let's Encrypt SSL on Apache running on CentOS 7.

Step 1 : Ensure the domain has DNS records set up to verify ownership.

Step 2 : Update your CentOS 7 system:

sudo yum update

Step 3 : Install Certbot and python-certbot-apache:

sudo yum install certbot python-certbot-apache

Step 4 : Create a configuration file for your domain (example.devtutorial.io) and add the configuration:

sudo nano /etc/httpd/conf.d/example.devtutorial.io.conf

Inside the file, add the following configuration:

<VirtualHost *:80>
    ServerAdmin webmaster@devtutorial.io
    DocumentRoot /var/www/html/example.devtutorial.io
    ServerName example.devtutorial.io

    ErrorLog /var/log/httpd/example.devtutorial.io_error.log
    CustomLog /var/log/httpd/example.devtutorial.io_access.log combined

    <Directory /var/www/html/example.devtutorial.io>
        AllowOverride All
    </Directory>

</VirtualHost>

Step 5 : Create a directory for your domain (example.devtutorial.io) and create an index.html file:

sudo mkdir -p /var/www/example.devtutorial.io
echo "Hello, this is example.devtutorial.io" | sudo tee /var/www/html/example.devtutorial.io/index.html

Step 6 : Test the Apache configuration:

sudo apachectl configtest

Step 7 : Restart Apache:

sudo systemctl restart httpd

Step 8 : Obtain SSL certificate:

sudo certbot --apache -d example.devtutorial.io

- Enter your email address: [Enter your email]

-. Agree to the terms of service: y

- Share your email address: y

- Successful message.

Step 9 : Test SSL certificate renewal:

sudo certbot renew --dry-run

Step 10 : Visit your domain to verify the SSL installation.

Congratulations! You have successfully installed Let's Encrypt SSL on Apache running on CentOS 7.