Linux 技术手札

RHEL / CentOS 7 安装 Let’s encrypt

Let’s Encrypt 是一个免费及开放的提供凭证的机构(CA), 以下是在 RHEL 及 CentOS 7 将 Let’s encrypt 配置到 Apache 的方法。

先安装 git 及 EPEL repo:

# yum install git epel-release

安装 Let’s encrypt 所需套件:

# yum install gcc libffi-devel python-devel openssl-devel

然后下载 Let’s encrypt:

# cd /root
# git clone https://github.com/letsencrypt/letsencrypt

这时系统会将 Let’s encrypt 的最新档案下载到 /root/letsencrypt, 执行以下 script SSL certificate:

# cd /root/letsencrypt
# ./letsencrypt-auto certonly -a standalone -d yourdomain.com -d www.yourdomain.com

Let’s encrypt 会将凭证档案放到 /etc/letsencrypt/live/.

接着可以配置 Apache, 先安装 mod_ssl:

# yum install mod_ssl

然后开启储存 VirtualHost 设定的档案, 例如 /etc/httpd/sites-enabled/www.your-domain.com, 在档案内应该已经有 VirtualHost 的 HTTP (埠号 80) 的设定, 加入 HTTPS (埠号 443) 的设定

将上面的 “www.your-domain.com” 换成你的网站 domain, 然后重新启动 Apache:

# systemctl restart httpd

最后可以透过存取 HTTPS 页面测试是否成功配置, 例如: “https://www.your-domain.com”.

Exit mobile version