How to make HTTPS default on Apache HTTP Server (CentOS 7)

Posted: 2016-09-17
  1. Install required packages.
    yum install epel-release
    yum install httpd mod_ssl python-certbot-apache
  2. Start and enable Apache.
    systemctl start httpd
    systemctl enable httpd
  3. Allow access via HTTP and HTTPS.
    firewall-cmd --zone=public --permanent --add-service=http
    firewall-cmd --zone=public --permanent --add-service=https
    firewall-cmd --reload
  4. Edit /etc/httpd/conf/httpd.conf.
    ServerName <your-domain>
  5. Edit /etc/httpd/conf.d/ssl.conf.
    SSLCertificateFile /etc/letsencrypt/live/<your-domain>/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/<your-domain>/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/<your-domain>/chain.pem
  6. Edit /etc/httpd/conf.d/<your-domain>.conf
    <VirtualHost *:80>
    Redirect permanent / https://<your-domain>/
  7. Restart Apache HTTP Server.
    systemctl restart httpd
  8. Install certificate. (Reference:
    certbot --apache -d <your-domain>