Enable HTTPS on an Apache web server by activating the mod_ssl module. This guide covers the prerequisite steps for installing a Secure Sockets Layer (SSL)/Transport Layer Security (TLS) certificate, with commands for Linux and instructions for Windows.
Enable the mod_ssl module on Linux
Enable the mod_ssl module
Run the following steps as the root user or a user with sudo permissions.
These steps apply to Apache 2.x.
CentOS/RHEL
Check the module status.
sudo httpd -M | grep ssl_moduleIf the output contains
ssl_module, themod_sslmodule is enabled. You can then install the certificate.Install the module.
Run the command for your OS version to install the module. The installation automatically creates the configuration file
/etc/httpd/conf.d/ssl.conf.CentOS/RHEL 8 and later
sudo dnf install -y mod_sslCentOS/RHEL 7 and earlier
sudo yum install -y mod_ssl
Debian/Ubuntu
Check the module status.
sudo apache2ctl -M | grep ssl_moduleIf the output contains
ssl_module, themod_sslmodule is enabled. You can then install the certificate.Enable the module.
sudo a2enmod sslIf the command returns an error, such as
a2enmod: command not foundorModule ssl does not exist, your Apache installation might be missing core files. To fix this, update your package list and reinstall Apache.NoteBefore running the reinstallation commands below, make sure to back up all your Apache configuration files.
# Update the package list. sudo apt update # Force reinstall to restore any missing core files. sudo apt install --reinstall apache2Enable the module again:
sudo a2enmod sslCheck the module status again:
sudo apache2ctl -M | grep ssl_moduleIf the output contains
ssl_module, themod_sslmodule is installed and enabled.
Install an SSL certificate
Enable the mod_ssl module on Windows
This topic uses Apache 2.4.x installed in C:\Apache24 as an example. Adjust the file paths in the instructions to match your actual installation directory.
Enable the mod_ssl module
Check the module status.
Navigate to the
C:\Apache24\modulesdirectory. If themod_ssl.sofile is present, themod_sslmodule is available. If the file is not present, go to the Apache official website to download and reinstall the latest version of Apache for Windows.Enable the module.
Use a text editor to open the main Apache configuration file
httpd.confas an administrator (for example,C:\Apache24\conf\httpd.conf). In the file, find and uncomment the following two lines by removing the leading#symbol:LoadModule socache_shmcb_module modules/mod_socache_shmcb.so LoadModule ssl_module modules/mod_ssl.soSave the file and close the editor.
Install an SSL certificate
For more information, see Install an SSL certificate on an Apache server (Windows).