How to Configure Apache Server with SSL certificates (https) in CentOS 7, Redhat 7, Fedora - Linux tech Solutions

Share on :

How to Configure Apache Server with SSL certificates (https) in CentOS 7, Redhat 7, Fedora

In cryptography and computer security, a self-signed certificate is an identity certificate that is signed by the same entity whose identity it certifies. This term has nothing to do with the identity of the person or organization that actually performed the signing procedure. In technical terms a self-signed certificate is one signed with its own private key.

Http/Apache is used to host a single website or multiple website on system with static IP address.The Apache HTTP Server, is free and open-source cross-platform web server software, released under the terms of Apache License 2.0. Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation.
Package httpd , mod_ssl , openssl(To Generate SSL Certificate)

Ports :-

http - 80

https - 443

Selinux context httpd_sys_content_t

Main Configuration filfe  /etc/httpd/conf/httpd.conf

Document root   /var/www/html

Server Configuration :-

To configure Apache server we must have an static ip.

1 )first of all we will install the httpd , mod_ssl , openssl packages :-

[[email protected] ~]# yum  install  httpd  mod_ssl  openssl  -y

2 )Now we will create our own configuration file in /etc/httpd/conf.d

You can create with the configuration file with any name but the file extension must be .conf .

[[email protected] ~]# vim /etc/httpd/conf.d/web.conf

In this configuration file you have to give the following parameters:-

3)Now we will generate the ssl certificates :-

[[email protected] ~]# openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt
[Here specify the country name, State, Locality, Organisation name, Common name, Email Address] or just press enter don't want to give.

4)Now just move the Generated server.crt file and server.key file to their desired Locations.

[[email protected] ~]#mv server.crt /etc/pki/tls/cert/
[[email protected] ~]#mv server.key /etc/pki/tls/private/

5)Now go to the hosts file and edit the entries.

[[email protected] ~]# vim /etc/hosts
# [Your IP]     [Your Domain]
172.25.1.30    www.gaurav.com

6)Now Create a file in the Document root directory.

[[email protected] ~]#cd /var/www/html
[[email protected] ~]#vim index.html
#[Your HTML code you want to add to your website]
My Website

7)Now start the httpd service and enable it.

[[email protected] ~]#systemctl start httpd
[[email protected] ~]#systemctl enable httpd

If there is any error during running the httpd service then there is some mistake in the coniguration file.
To check the sytax of the configuration file.

[[email protected] ~]#httpd -t

8)Now apply the firewall rule.

[[email protected] ~]#firewall-cmd --permanent --add-service=https
[[email protected] ~]#firewall-cmd --reload

9)Now open your website on firefox.

[[email protected] ~]#firefox https://www.gaurav.com

[It will show connection is not secure then click on "Advanced" and then click on "Add Exceptions" and then on click on "Confirm Security Exception".


Share on :

You may also like...

3 Responses

  1. DedicatedHosting4u says:

    The article has genuinely peaks my interest. I’m planning to marker your website and maintain checking for brand new details. i actually idolized reading your journal, valuable data.

    Offshore dedicated

  2. Rajani says:

    Excellent article.Thanks for sharing….
    Docker Training in Hyderabad
    Docker and Kubernetes Online Training
    Docker Training

  3. Full Stack Developer says:

    Thank you for posting.
    DevOps Online Training

Leave a Reply

Your email address will not be published. Required fields are marked *