In this post, I will introduce how to install the SSL certificate for WordPress.
I did some research and tried different methods. Now I will provide the simplest ways.
- Apply for an SSL certificate;
- Download the certificate and sent it to the server;
- Do the following command:
sudo yum install mod_ssl;
- Add a file httpd-ssl.conf to
/etc/httpd/conf.d/, which will be loaded by httpd.conf in
<VirtualHost 0.0.0.0:443> DocumentRoot "/var/www/html" ServerName www.domain.com SSLEngine on SSLCertificateFile /path/to/certificate/2_www.domain.com_cert.crt SSLCertificateKeyFile /path/to/certificate/3_www.domain.com.key SSLCertificateChainFile /path/to/certificate/1_root_bundle.crt </VirtualHost>
- Restart Apache service
Apply for an SSL certificate
I applied a free personal SSL certificate in the same site (Tencent Cloud) where I bought my domain.
I came across some bugs after adding the SSL configuration file.
[root@10-255-0-79 ~]# apachectl configtest AH00526: Syntax error on line 5 of /etc/httpd/conf.d/httpd-ssl.conf: Invalid command 'SSLEngine', perhaps misspelled or defined by a module not included in the server configuration
I found that in my Apache installation, mod_ssl.so was outright missing. It turns out it is separate from the base installation and was under the package mod_ssl in the yum package manager. Simply do
sudo yum install mod_ssl solve this problem.