面向中文开发者的 AWS 实战知识库 代维服务
上云咨询

Apache 配置 SSL 证书教程(mod_ssl)

导出 PDF 浅色排版、带版权水印,可在打印窗口另存为 PDF
Apache 配置 SSL 证书教程(mod_ssl) — Apache 配置 SSL 证书教程(mod_ssl)

1. 启用模块

a2enmod ssl headers
systemctl restart apache2

2. 虚拟主机配置

<VirtualHost *:443>
    ServerName example.com
    SSLEngine on
    SSLCertificateFile      /etc/ssl/example.com.pem
    SSLCertificateKeyFile   /etc/ssl/example.com.key
    SSLCertificateChainFile /etc/ssl/example.com.ca
    Header always set Strict-Transport-Security "max-age=31536000"
</VirtualHost>

Apache 2.4.8+ 可把中间证书与站点证书合并进 SSLCertificateFile,不再需要 ChainFile 指令。

3. 验证

apachectl configtest 通过后 reload,浏览器访问 https 确认小锁正常。