< All Docs

How to install SSL on CentOS-7.3 with httpd server

Create a Microhost account to try this guide with a $50 credit.

Table of Content

What is SSL

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.


  • 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 SSL certificate file(csr) using below command

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


  • 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.

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

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

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)"

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

Previous How to install phpMyAdmin on Linux
Next How to install Tomcat 10 on Ubuntu server
Table of Contents