Ensuring the security of web applications is crucial in today's digital landscape, and one fundamental component of security is secure encrypted communication. An SSL/TLS certificate is a standard security technology used to encrypt data transmitted between a web server and a web browser. In this article, we will demonstrate how to install and configure an SSL certificate on Apache and Nginx web servers running on the CentOS 7 operating system.
Preparation
Before proceeding with the installation of an SSL certificate, ensure that your system is up to date and that you have Apache or NGINX web server installed.
-
System Update:
sudo yum update
-
Apache Installation:
sudo yum install httpd
-
NGINX Installation:
sudo yum install nginx
Generating CSR and Installing SSL Certificate
Generating Key and CSR (Certificate Signing Request)
Firstly, you need to generate a private key and CSR, which you will submit to a Certificate Authority (CA) to obtain an SSL certificate.
sudo openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr
Installing SSL Certificate
Upon receiving the SSL certificate from the CA, place the certificate files on your server. You will need the primary certificate (yourdomain.crt
) and intermediate certificates (often provided in a file named chain.pem
or bundle.crt
).
Apache Configuration
Create a new configuration file for your domain or modify an existing one in /etc/httpd/conf.d/
.
<VirtualHost *:443>
ServerName yourdomain.com
SSLEngine on
SSLCertificateFile /cesta/k/yourdomain.crt
SSLCertificateKeyFile /cesta/k/yourdomain.key
SSLCertificateChainFile /cesta/k/chain.pem
</VirtualHost>
Restart Apache:
sudo systemctl restart httpd
NGINX Configuration
-
Modify the configuration file for your domain in
/etc/nginx/conf.d/
.
server {
listen 443 ssl;
server_name yourdomain.com;
ssl_certificate /cesta/k/yourdomain.crt;
ssl_certificate_key /cesta/k/yourdomain.key;
ssl_trusted_certificate /cesta/k/chain.pem;
}
Restart NGINX:
sudo systemctl restart nginx
The installation and configuration of an SSL certificate are critical steps in securing communication between your web server and clients. Follow the steps outlined above for Apache or NGINX on CentOS 7 to ensure encrypted connections and safeguard the data of your users.