I have an EC2 instance that is using Amazon\'s custom linux install with built in apache. This install also has openssl installed. That being said, there does not appear t
You should install the SSL module, since mod SSL does not ship with most instances by default, but that depends on the Apache version you are using in your AWS instance. To check which one you are using, you can run this command in your command line:
httpd -v
For Apache 2.2
yum install mod_ssl
For Apache 2.4
yum install mod24_ssl
I managed to enable SSL on my ec2 instance and to install a free ssl certificate from startssl.com. I made a few mistakes, this is the basic approach:
Web Server SSL/TLS Certificate
ssl.encrypted.key
someplacesudo openssl rsa -in ssl.encrypted.key -out ssl.unencrpted.key
sudo yum install mod_ssl
sudo vi /etc/pki/tls/certs/localhost.crt
:%d
to delete the existing certificate if required[ESC] wq
sudo vi /etc/pki/tls/private/localhost.key
[ESC] wq
apachectl configtest
sudo service httpd restart
sudo kill -9 httpd
Try this command:
yum install mod_ssl
Here's what worked for me, via shell, with a wildcard cert that had a CA bundle (on Lightsail servers, HTTPS/443 enabled). Mileage may vary. Test on https://www.digicert.com/help/ after install. For brevity, I've shortened the certs/keys here (obviously).
It's worth noting also that I did not need to set up a VirtualHost for the domain.
# Overwrite these files on Amazon Linux + mod_ssl (or mod24_ssl)
# /etc/pki/tls/certs/ca-bundle.crt
# /etc/pki/tls/certs/localhost.crt
# /etc/pki/tls/private/localhost.key
## BEGIN
# INSTALL AS ROOT
sudo -su root
sudo cat > /etc/pki/tls/certs/localhost.crt <<EOF
-----BEGIN CERTIFICATE-----
MIIF7DCCBNSgAwIBAgIMNY9yk7s651tb2YasMA0GCSqGSIb3DQEBCwUAMEwxCzAJ
KoZIhvcNAQELBQADggEBACu8MsClqLbO1NqjXw+igERhLRkISgnkIjB1p69zh3V0
/3b68mkC+8pL3HNLgL0qIM9sPKKOl/Iyky2EfwfQDoZEWNB0qWKIOovH5Oj9z5DE
-----END CERTIFICATE-----
EOF
sudo cat > /etc/pki/tls/private/localhost.key <<EOF
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCL6UsW9yC0Faev
1zeEJcF6E7P6XYqT25rWMj5xzUM8gi/4nLpGr+tOBlFJYSbLlEHJKG6QLO9Ku896
MwTtWyOrTlPtpJEi9LUrLmOUXtD1WN2Ekql/ZLaO7pxUtVTRF4MyYspGgU1ZjkxY
vQLnZs85bnG2dLz7Q4xxlj4=
-----END PRIVATE KEY-----
EOF
sudo cat > /etc/pki/tls/certs/ca-bundle.crt <<EOF
-----BEGIN CERTIFICATE-----
MIIESzCCAzOgAwIBAgIOSMqBefg+ikLz9c3isT8wDQYJKoZIhvcNAQELBQAwTDEg
bFNpZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMTYxMDE0MDAwMDAwWhcNMjQw
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG
DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME
-----END CERTIFICATE-----
EOF
# RESTART
sudo service httpd restart
#DONE
A summary of what needs to be done to enable SSL on apache server on EC2:
NameVirtualHost *:443 <VirtualHost *:443> ServerName www.example.com # other configurations SSLEngine on SSLCertificateFile /etc/httpd/conf/ssl.crt/mydomain.crt SSLCertificateKeyFile /etc/httpd/conf/ssl.key/mydomain.key </VirtualHost>
Finally, don't forget to open port 443 on your EC2 instance
If you are using Amazon Lightsail, be sure to go into Networking from the Lightsail dashboard and add HTTPS/443 in your Firewall: