Home > Article > Operation and Maintenance > SSL certificate configuration for building web servers on CentOS 6 and CentOS 7
SSL certificate configuration for building web servers on CentOS 6 and CentOS 7
When building a web server, in order to ensure data security, we often use SSL certificates to encrypt website access. This article will introduce how to configure an SSL certificate when building a web server on CentOS 6 and CentOS 7.
Before we start, we need to prepare the following files:
First, we need to ensure that our operating system has the Apache server and related SSL modules installed. On CentOS 6, you can use the following command to install Apache:
sudo yum install httpd sudo yum install mod_ssl
On CentOS 7, you need to use the following command:
sudo yum install httpd sudo yum install mod_ssl
After the installation is complete, we need to install it in the Apache configuration file Configure the SSL certificate. On CentOS 6, the configuration file is /etc/httpd/conf.d/ssl.conf
, on CentOS 7 it is /etc/httpd/conf.d/ssl.conf
. Open the file for editing.
First of all, we need to find the following lines of code, uncomment and modify it to your own certificate file path:
SSLCertificateFile /path/to/your/certificate.crt SSLCertificateKeyFile /path/to/your/privatekey.key
If you purchased the CA certificate, you also need to find the following lines of code to modify:
SSLCertificateChainFile /path/to/your/CA.crt
After saving and closing the file, we need to restart the Apache server for the configuration to take effect. On CentOS 6, you can use the following command:
sudo service httpd restart
On CentOS 7, use the following command:
sudo systemctl restart httpd
After restarting, the Apache server will load the SSL certificate specified in the configuration file.
In order to test whether the configuration is successful, we can use the curl command to access the website and check whether the returned result contains information related to the SSL certificate. You can use the following command:
curl -I https://yourwebsite.com
where yourwebsite.com
is your website domain name.
If the returned result contains information similar to the following, the SSL certificate configuration is successful:
HTTP/2 200 ... Server: Apache ... SSL certificate verify ok.
At this point, we have successfully built a web server with an SSL certificate on CentOS 6 and CentOS 7 .
Summary:
This article introduces how to configure the SSL certificate when building a web server on CentOS 6 and CentOS 7. When building a web server, using an SSL certificate can ensure data security. By modifying the configuration file of the Apache server and restarting the server, we can easily add an SSL certificate to the website.
The above is the detailed content of SSL certificate configuration for building web servers on CentOS 6 and CentOS 7. For more information, please follow other related articles on the PHP Chinese website!