How Can We Help?

Special Offer

Deploy your Cloud Server now and get $100 in Free Credits!

Get Started

How to install SSL on CentOS-7.3 with httpd server

Table of Content
How to install SSL on CentOS-7.3 with httpd server
How to install SSL on CentOS-7.3 with httpd server

What is SSL

Before learning, how to install SSL on CentOS-7.3 with httpd server first learn that SSL, or Secure Sockets Layer, is an Internet security technology based on encryption. It was created by Netscape in 1995 to provide privacy, authentication, and data integrity for Internet interactions. SSL is the forerunner of the current TLS encryption protocol.

A certificate that is self-signed will encrypt communications between your server and any clients. Users cannot use the certificate to automatically authenticate the identity of your server, since it is not certified by any of the trustworthy certificate authorities available in web browsers.

If you do not have a domain name linked with your server and the encrypted web interface is not user-facing, a self-signed certificate may be suitable.

Prerequisites:

  • yum server should be configured
  • Internet should be working on the machine
  • Super user or normal user with SUDO privileges

OS and other important files:

  • We have used CentOS and Apache( HTTPD ) service
  • Default Configuration file: /etc/https/conf/httpd.conf
  • SSL Virtual Host file: /etc/httpd/conf.d/domain.com.conf

Steps to install the SSL:

Step 1: Install the Apache server on your Centos server using the below command.

yum install httpd

Step 2: Start and enable the httpd service on your server so that you can use the httpd services

systemctl start httpd
systemctl enable httpd

Step 3: Now to check the whether your httpd service is running fine or not, go to browser and search your server ip on your browser

Step 4: To generate a CSR we need to install openssl and mod_ssl package.

yum install openssl mod_ssl -y 

Step 5: Now if we want to test apache server with a sample source code. Go to the /var/www/html directory and create an index. html file and paste the content shown in the below screenshot.

vim /var/www/html/index.html

Step 6: Now generate the CSR and Private key file using below command

openssl req -new -newkey rsa:2048 -nodes -keyout mydomain.key -out mydomain.csr

Note:

  • Here you will be asked to enter a few details. So please enter them as you want.
  • The above command will create a csr and certificate key file in the current working directory.
  • In common name, for the subdomain, you must include an asterisk if you are requesting a unique wildcard SSL certificate. In such scenario, *.mydomain.com may serve as an example. Never enter any special characters in this area, including "http://", "https://", or any other variation. Never add text after the top-level domain. Your common name, for instance, should finish in.com,.net, or the other extension you are requesting.
Generate CSR and private to install SSL
Generate CSR and private to install SSL

Congratulations, a CSR file has been generated.

When getting an SSL certificate, you must copy and paste the whole contents of the CSR file to your Certificate Authority.
The lines that say "BEGIN CERTIFICATE REQUEST" and "END CERTIFICATE REQUEST" must be included.

Step 7: To set up the virtual hosts to display the new certificate. Create a file in /etc/httpd/conf.d/

vim /etc/httpd/conf.d/domain.com.conf

Paste the content in the newly created file

  ServerName 103.127.29.172
  DocumentRoot /var/www/html
  SSLEngine on
  SSLCertificateFile /etc/pki/tls/certs/apache-selfsigned.crt
  SSLCertificateKeyFile /etc/pki/tls/private/apache-selfsigned.key

If you are facing any issue such as "Certificate chain is incomplete, missing intermediate(s)", then you need to follow the below step

  • Append the line in your VirtualHost entry. SSLCertificateChainFile /etc/pki/tls/certs/gd.bundle

Step 8: Now Restart the apache service and go to your browser and browse https://server_ip

 systemctl restart httpd 

Now click on "proceed to .... (safe)"

SSL installed on website
SSL installed on website

Please note that the lock sign before the tag in the search bar of the browser.

In this tutorial, you have learned how to install SSL on CentOS-7.3 with httpd server

Also read: How to install SSL on Ubuntu with Apache2, Install SSL on Ubuntu server using Nginx

Special Offer

Deploy your Cloud Server now and get $100 in Free Credits!

Get Started
Table of Contents