How to make HTTPS default on Apache HTTP Server (CentOS 7)
Posted: 2016-09-17
- Install required packages.
yum install epel-release yum install httpd mod_ssl python-certbot-apache
- Start and enable Apache.
systemctl start httpd systemctl enable httpd
- 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
- Edit
/etc/httpd/conf/httpd.conf
.ServerName <your-domain>
- 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
- Edit
/etc/httpd/conf.d/<your-domain>.conf
<VirtualHost *:80> Redirect permanent / https://<your-domain>/ </VirtualHost>
- Restart Apache HTTP Server.
systemctl restart httpd
- Install certificate. (Reference: https://certbot.eff.org/all-instructions/#centos-rhel-7-apache)
certbot --apache -d <your-domain>