Last active
January 17, 2020 19:19
-
-
Save dbtutor/f10581a889414028e083549fa6f81eec to your computer and use it in GitHub Desktop.
Apache HTTP Server SSL Installation with Demo Certificate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| sudo yum -y install httpd24-mod_ssl | |
| sudo openssl req -x509 -nodes -days 365 -subj /C=IN/ST=WB/L=Kolkata/CN=OracleCertificateAuthority -newkey rsa:1024 -keyout privatekey.pem -out cert.pem | |
| sudo openssl x509 -in cert.pem -out rootcert.crt | |
| sudo mkdir /etc/httpd/conf/ssl | |
| sudo cp cert.pem /etc/httpd/conf/ssl/cert.pem | |
| sudo cp privatekey.pem /etc/httpd/conf/ssl/privatekey.pem | |
| sudo cp cert.pem /etc/httpd/conf/ssl/root_cert.pem | |
| sudo restorecon -RvF /etc/httpd/conf/ssl | |
| sudo firewall-cmd --reload | |
| sudo semanage port -m -t http_port_t -p tcp 80 | |
| sudo sed -i "/Listen 443 https/c\ | |
| #Listen 443 https\n\ | |
| Listen 443\n\ | |
| <VirtualHost *:443>\n\ | |
| ServerName <<SERVER_NAME_OR_IP_ADDRESS>>\n\ | |
| SSLEngine on\n\ | |
| SSLCertificateFile \"/etc/httpd/conf/ssl/cert.pem\"\n\ | |
| SSLCertificateKeyFile \"/etc/httpd/conf/ssl/privatekey.pem\"\n\ | |
| </VirtualHost>\n\ | |
| " /etc/httpd/conf.d/ssl.conf | |
| sudo apachectl configtest | |
| sudo apachectl restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment