Installing SSL Certificate on Apache in CentOS
There are plenty of article of hosting an app on Linux systems, most of these are for Ubuntu and uses Nginx, however for those developers or DevOps teams who are using Apache on CentOS, this info is little scattered. In this article, first of a series, I will explain the method of successfully applying the SSL certificates in Apache on CentOS.
If you are looking for either of these, keep reading the upcoming articles in this series:
- Hosting your Nodejs app on CentOS with Apache
- Hosting Nodejs app on Ubuntu with Nginx
- Hosting ReactJs App on CentOS with Apache
Installing SSL Certification on Apache
Step 1: Upload Certificate to Server
Upload your certificate files to the directory on server where you keep your certificate and key files. Typically, this directory is /etc/ssl/
for your certificate.crt and ca_bundle.crt files, and /etc/ssl/private/
for your private.key file. But feel free to choose per your preference.
Step 2: Edit Configuration File
Find the Apache configuration file on your server. Depending on the server and OS version you are running on, the configuration file is stored in different directories. Typically, you could search the directories etc/httpd/
, /etc/apache2/
or /etc/httpd/conf.d/ssl.conf
for files named httpd.conf
, apache2.conf
or ssl.conf
. In CentOS, typically it is /etc/apache2/conf/httpd.conf
.
Find the entry for your host Ctrl + W
if using nano, and /
if using vi. Here’s how it looks like typically — find the ssl_module
in there and make changes to the lines in bold.
<VirtualHost [IP ADDRESS]:443>
ServerName subdomain.domain.com
ServerAlias subdomain.domain.com www.subdomain.domain.com
DocumentRoot /var/www/
ServerAdmin admin@domain.com
ErrorLog /www/home/logs/error_log
...
<IfModule ssl_module>
SSLEngine on
SSLCertificateFile /etc/ssl/certificate.crt
SSLCertificateKeyFile /etc/ssl/private.key
SSLCertificateChainFile /etc/ssl/ca_bundle.crt
</IfModule>
...
</VirtualHost>
Step 3: Restart Apache after updating the config file
systemctl restart httpd
Step 4: (For sanity ) Check the status of Apache after restart
systemctl status httpd
Which should show running fine, if everything went good.