2
Install Mod SSL
In order to set up the self-signed certificate, we first have to be sure that mod_ssl, an Apache module that provides support for SSL encryption, is installed the server:
yum -y install httpd mod_sslsystemctl enable httpd.servicesystemctl start httpd.service3. Set Up the Certificate
First copy your certificate file in /etc/ssl/private
mkdir -p /etc/ssl/private
chmod 700 /etc/ssl/private
The next thing to do is to set up the virtual hosts to display the new certificate.
# vi /etc/httpd/conf.d/ssl.conf<VirtualHost *:443>DocumentRoot /var/www/htmlServerName www.example.comSSLEngine onSSLCertificateFile /etc/ssl/private/certificate.crtSSLCertificateKeyFile /etc/ssl/private/private.key</VirtualHost>
When you are finished making these changes, you can save and close the file.
Adjust the file names to match your certificate files:
SSLCertificateFile should be your certificate file (eg. your_domain_name.crt).
SSLCertificateKeyFile should be the key file generated when you created the CSR.
4. Redirect to HTTPS
To redirect all traffic to be SSL encrypted, create and open a file ending in .conf in the /etc/httpd/conf.d directory:
# vi /etc/httpd/conf/httpd.conf<VirtualHost *:80> ServerName www.example.com Redirect "/" "https://www.example.com/"</VirtualHost>
Save and close this file when you are finished.
5. Test your Apache config before restarting.
# apachectl configtest
Restart Apache.
# systemctl restart httpd
LLL