How to Install mod_ssl on RHEL/CentOS 7 with Apache Web Server?
Last Updated :
15 Jul, 2024
Strong cryptography comes to the Apache HTTP Server via the mod_ssl module with Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols. Enabling SSL on your Apache web server enhances security by encrypting the data between the server and clients.
There are several methods to install mod_ssl on RHEL/CentOS 7 with Apache web server which are as follows:
Installing mod_ssl via YUM Package Manager
Step 1: Update System Packages
First, you need to ensure your system packages are up to date. Run the following command in a terminal:
sudo yum update -y
Step 2: Installing Apache HTTP Server
In the case where Apache is not yet installed, it can easily be installed with the following command:
sudo yum install httpd -y
Step 3: Install the mod_ssl
The installation can be made with the command:
sudo yum install mod_ssl -y
apachectl -M | grep ssl
Step 4: Start and Enable Apache
Start Apache Web Server and enable it to start on boot.
sudo systemctl start httpd
sudo systemctl enable httpd
Step 5: Firewall Configuration
Can pass HTTPS traffic by the firewall:
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Step 6: Generating SSL Certificates
You can create a self-signed SSL certificate with the 'openssl' command:
sudo openssl req -newkey rsa:2048 -nodes -keyout /etc/pki/tls/private/httpd-selfsigned.key -x509 -days 365 -out /etc/pki/tls/certs/httpd-selfsigned.crt
Fill in any information you are asked for.
Step 7: Apache Setup with SSL
Now modify the SSL configuration file at '/etc/httpd/conf.d/ssl.conf':
sudo vi /etc/httpd/conf.d/ssl.conf
Please update the below lines with your certificate paths:
SSLCertificateFile /etc/pki/tls/certs/httpd-selfsigned.crt
SSLCertificateKeyFile /etc/pki/tls/private/httpd-selfsigned.key
Step 8: Rebooting Apache
Restart Apache service to effect the changes:
sudo systemctl restart httpd
Manual Installation from Source
This is the process where one downloads the source code and then compiles it manually. This method comes in where there is a need for a specially customized version of mod_ssl.
Step 1: Installation of Required Packages
Install the packages for building mod_ssl:
sudo yum groupinstall 'Development Tools' -y
sudo yum install openssl openssl-devel -y
Step 2: Download Source Code of Apache HTTPD and mod_ssl
Download the Apache HTTP Server and mod_ssl source code from appropriate websites:
wget https://downloads.apache.org/httpd/httpd-2.4.46.tar.gz
wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
Step 3: Extract Source Files
Extract the downloaded tar files:
tar -xzf httpd-2.4.46.tar.gz
tar -xzf openssl-1.1.1k.tar.gz
Step 4: Build and install OpenSSL
Enter the OpenSSL directory and build it:
cd openssl-1.1.1k
./config
make
sudo make install
Step 5: Build and Install Apache with mod_ssl
Navigate to the Apache directory and configure it with SSL support:
cd ../httpd-2.4.46
./configure --enable-ssl --with-ssl=/usr/local/ssl --enable-so
make
sudo make install
Step 6: Start Apache
Start Apache web server:
sudo /usr/local/apache2/bin/apachectl start
Step 7: Let Apache Use SSL
Edit the file httpd-ssl.conf located in the conf/extra directory:
sudo vi /usr/local/apache2/conf/extra/httpd-ssl.conf
Update the following lines with your certificate paths:
SSLCertificateFile /usr/local/apache2/conf/server.crt
SSLCertificateKeyFile /usr/local/apache2/conf/server.key
Step 8: Restart Apache
Restart Apache to apply changes:
sudo /usr/local/apache2/bin/apachectl restart
Conclusion
Adding mod_ssl to RHEL/CentOS 7 allows you to implement and configure the SSL module within Apache, thereby enhancing security with the power to permit encrypted communication.
Similar Reads
Non-linear Components
In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co
11 min read
JavaScript Tutorial
JavaScript is a programming language used to create dynamic content for websites. It is a lightweight, cross-platform, and single-threaded programming language. JavaScript is an interpreted language that executes code line by line providing more flexibility. HTML adds Structure to a web page, CSS st
11 min read
Web Development
Web development is the process of creating, building, and maintaining websites and web applications. It involves everything from web design to programming and database management. Web development is generally divided into three core areas: Frontend Development, Backend Development, and Full Stack De
5 min read
Class Diagram | Unified Modeling Language (UML)
A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact
12 min read
React Interview Questions and Answers
React is an efficient, flexible, and open-source JavaScript library that allows developers to create simple, fast, and scalable web applications. Jordan Walke, a software engineer who was working for Facebook created React. Developers with a Javascript background can easily develop web applications
15+ min read
Spring Boot Tutorial
Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance
10 min read
JavaScript Interview Questions and Answers
JavaScript (JS) is the most popular lightweight, scripting, and interpreted programming language. JavaScript is well-known as a scripting language for web pages, mobile apps, web servers, and many other platforms. It is essential for both front-end and back-end developers to have a strong command of
15+ min read
HTML Tutorial
HTML stands for HyperText Markup Language. It is the standard language used to create and structure content on the web. It tells the web browser how to display text, links, images, and other forms of multimedia on a webpage. HTML sets up the basic structure of a website, and then CSS and JavaScript
10 min read
AVL Tree Data Structure
An AVL tree defined as a self-balancing Binary Search Tree (BST) where the difference between heights of left and right subtrees for any node cannot be more than one. The absolute difference between the heights of the left subtree and the right subtree for any node is known as the balance factor of
4 min read
Backpropagation in Neural Network
Backpropagation is also known as "Backward Propagation of Errors" and it is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network. In this article we will explore what
10 min read