Detailed explanation of SSL configuration differences between Apache 2.2, 2.4, and 2.5 versions to help you correctly configure SSL certificates
All Apache versions need to load SSL module to use HTTPS. Module loading methods differ slightly between versions:
LoadModule ssl_module modules/mod_ssl.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
This is the most important configuration difference between different Apache versions:
<VirtualHost *:443>
ServerName yourdomain.com
DocumentRoot "/var/www/html"
SSLEngine on
SSLCertificateFile /path/to/your_domain.crt
SSLCertificateKeyFile /path/to/your_domain.key
SSLCertificateChainFile /path/to/intermediate_ca.crt
</VirtualHost>
<VirtualHost *:443>
ServerName yourdomain.com
DocumentRoot "/var/www/html"
SSLEngine on
SSLCertificateFile /path/to/fullchain.crt
SSLCertificateKeyFile /path/to/your_domain.key
# # Deprecated, but still available</VirtualHost>
SSLCertificateChainFile 指令已被弃用 - Starting from Apache 2.4.8, SSLCertificateChainFile directive has been deprecated<VirtualHost *:443>
ServerName yourdomain.com
DocumentRoot "/var/www/html"
SSLEngine on
SSLCertificateFile /path/to/your_domain.crt
SSLCertificateKeyFile /path/to/your_domain.key
SSLCertificateChainFile /path/to/intermediate_ca.crt # # Deprecated, but still available</VirtualHost>
| Configuration Item | Apache 2.2.x | Apache 2.4.x | Apache 2.5.x |
|---|---|---|---|
| SSLProtocol | SSLProtocol all -SSLv2 -SSLv3 | SSLProtocol all -SSLv2 -SSLv3 -TLSv1 | SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1 |
| Recommended Protocol | TLSv1.2 | TLSv1.2 TLSv1.3 | TLSv1.2 TLSv1.3 |
| SSLCipherSuite | SSLCipherSuite HIGH:!aNULL:!MD5 | SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256 | SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256 |
| HTTP/2 Support | ❌ Not Supported | ✅ Supported (requires mod_http2) | ✅ Supported |
| OCSP Stapling | ❌ Not Supported | ✅ Supported | ✅ Supported |
<VirtualHost *:443>
ServerName yourdomain.com
DocumentRoot "/var/www/html"
SSLEngine on
SSLCertificateFile /path/to/your_domain.crt
SSLCertificateKeyFile /path/to/your_domain.key
SSLCertificateChainFile /path/to/intermediate_ca.crt
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite HIGH:!aNULL:!MD5
SSLHonorCipherOrder on
</VirtualHost>
<VirtualHost *:443>
ServerName yourdomain.com
DocumentRoot "/var/www/html"
SSLEngine on
SSLCertificateFile /path/to/fullchain.crt
SSLCertificateKeyFile /path/to/your_domain.key
# # Modern TLS Protocol Configuration SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384
SSLHonorCipherOrder on
# # HTTP/2 Support (requires mod_http2) Protocols h2 http/1.1
# # OCSP Stapling (improves performance) SSLUseStapling on
SSLStaplingCache "shmcb:logs/ssl_stapling(32768)"
SSLStaplingResponderTimeout 5
SSLStaplingReturnResponderErrors off
# # SSL Session Cache SSLSessionCache "shmcb:logs/ssl_scache(512000)"
SSLSessionCacheTimeout 300
</VirtualHost>
<VirtualHost *:80>
ServerName yourdomain.com
Redirect permanent / https://yourdomain.com/
</VirtualHost>
<VirtualHost *:80>
ServerName yourdomain.com
Redirect permanent / https://yourdomain.com/
</VirtualHost>
# # Or use mod_rewrite (more flexible)<VirtualHost *:80>
ServerName yourdomain.com
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</VirtualHost>
# Disable insecure protocolsSSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
# Use strong cipher suitesSSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384
# Enable HSTS (HTTP Strict Transport Security)Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
# Enable security headersHeader always set X-Frame-Options "SAMEORIGIN"
Header always set X-Content-Type-Options "nosniff"
Header always set X-XSS-Protection "1; mode=block"
# Linux
httpd -v
# # Orapache2 -v
# # Check loaded moduleshttpd -M | grep ssl
# # Test configuration file syntaxhttpd -t
# # Orapache2ctl configtest
# # If configuration is correct, will display "Syntax OK"
SSLCertificateChainFile: file '/path/to/chain.crt' does not exist or is emptySSL library error: error:140A90A1:SSL routines:SSL_CTX_new:unable to find ssl methodAH00558: httpd: Could not reliably determine the server's fully qualified domain name# Use online tools to verifyhttps://www.ssllabs.com/ssltest/
https://myssl.com/
# Use command line toolsopenssl s_client -connect yourdomain.com:443 -servername yourdomain.com
cp -r /etc/httpd /etc/httpd.backupcat your_domain.crt intermediate_ca.crt > fullchain.crtSSLCertificateChainFile,使用合并后的 fullchain.crthttpd -t Check syntaxsystemctl restart httpd