在打印窗口把「目标」选为「另存为 PDF」即可保存,页面已带 awsgood.com 版权水印。 返回原文

www.awsgood.com

Apache 配置 SSL 证书教程(mod_ssl)

2026-11-09 约 1 分钟

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 确认小锁正常。