SSL certificate configuration for building web servers on CentOS 6 and CentOS 7

PHPz
Release: 2023-08-05 20:30:41
Original
1601 people have browsed it

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:

  1. SSL certificate file (.crt)
  2. Private key file (.key)
  3. CA certificate file (optional, if you purchased the certificate from the CA organization)

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
Copy after login
Copy after login

On CentOS 7, you need to use the following command:

sudo yum install httpd sudo yum install mod_ssl
Copy after login
Copy after login

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
Copy after login

If you purchased the CA certificate, you also need to find the following lines of code to modify:

SSLCertificateChainFile /path/to/your/CA.crt
Copy after login

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
Copy after login

On CentOS 7, use the following command:

sudo systemctl restart httpd
Copy after login

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
Copy after login

whereyourwebsite.comis 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.
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!