【问题标题】:How to install lets encrypt ssl in amazon linux AMI?如何在 amazon linux AMI 中安装让我们加密 ssl?
【发布时间】:2023-03-21 14:28:01
【问题描述】:

如何在 amazon Linux AMI 中安装让我们加密 SSL。我想为我的域实施让我们加密 SSL。

【问题讨论】:

标签: ssl lets-encrypt


【解决方案1】:

网上有很多解决方案;我认为您必须继续尝试,直到找到适合您的方法。在大量实验之后,对我有用的是遵循 Apache 和 CentOS 6 的 certbot 说明。官方链接是 here,但为了保持一致性:

在终端中运行以下命令:

  1. 下载 Certbot
wget https://dl.eff.org/certbot-auto
sudo mv certbot-auto /usr/local/bin/certbot-auto
sudo chown root /usr/local/bin/certbot-auto
sudo chmod 0755 /usr/local/bin/certbot-auto
  1. 执行 Certbot
sudo /usr/local/bin/certbot-auto --apache

如果有错误消息,请阅读警告并运行(如果您觉得舒服):

sudo /usr/local/bin/certbot-auto --apache --debug

在这里,您可能会被要求完成一些相当直观的问题来配置您的安装。如果没有,对我有用的东西对你也不起作用。 :(

  1. 自动续订

测试更新您的证书是否有效:

sudo /usr/local/bin/certbot-auto renew --dry-run

如果是这样,请导航到系统的 crontab(通常在 /etc/crontab/ 附近)并添加以下代码以检查(并在必要时运行)并在每天午夜和中午自动更新:

0 0,12 * * * python -c 'import random; import time; time.sleep(random.random() * 3600)' && /usr/local/bin/certbot-auto renew 

【讨论】:

【解决方案2】:

这里我将解释如何在 Linux AMI 中配置 let's encrypt。我在我的 Linux AMI 中成功完成了它。我按照以下步骤完成了它。

 1. SSH into your server.
 2. Download certbot (the Let’s Encrypt client need to install for renew and install ssl): **wget https://dl.eff.org/certbot-auto** then **chmod a+x certbot-auto**
 3. Run certbot to fetch your certificates.follow the below code
    sudo ./certbot-auto --debug -v --server https://acme-v01.api.letsencrypt.org/directory certonly -d YOUR_DOMAIN [Replace your Domain in YOUR_DOMAIN placeholde]

 4. while generating it will ask you the recover or support email please add your email.

 5.  certbot will place your certs in the following paths…

      Certificate: /etc/letsencrypt/live/YOUR_DOMAIN/cert.pem
      Full Chain: /etc/letsencrypt/live/YOUR_DOMAIN/fullchain.pem
      Private Key: /etc/letsencrypt/live/YOUR_DOMAIN/privkey.pem

 6. Go to your apache config where you created a virtual host it can be either in httpd.conf or conf.d.

 7. Add the virtual host for 443 port

    <VirtualHost *:443>
    ServerAdmin ADMIN_EMAIL
    ServerName YOUR_DOMAIN
    ServerAlias www.YOUR_DOMAIN
    DocumentRoot "YOUR FOLDER PATH"
      AllowEncodedSlashes On

    ErrorLog "/var/log/httpd/YOUR_DOMAIN_error.log"
    CustomLog "/var/log/httpd/YOUR_DOMAIN-sslaccess.log" common

<Directory YOUR FOLDER PATH>
                DirectoryIndex index.php
                Options -Indexes
                AllowOverride All
        </Directory>
SSLEngine on
    SSLCertificateFile      /etc/letsencrypt/live/YOUR_DOMAIN/cert.pem
    SSLCertificateKeyFile   /etc/letsencrypt/live/YOUR_DOMAIN/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/YOUR_DOMAIN/fullchain.pem
</VirtualHost>

【讨论】:

    【解决方案3】:

    如果您运行的是 CentOS 7 或 8,则需要安装 Certbot,因为 Certbot-auto 已被弃用,并且在 CentOS 6 之后无法运行。

    您可以使用以下命令检查您运行的是哪个 CentOS。

    rpm -E %{rhel}
    

    并使用来自亚马逊的 tutorial 在 Amazon Linux 中安装 Certbot

    sudo yum update
    sudo yum install -y certbot python2-certbot-apache
    

    如果您收到“找不到包”错误,请尝试同一博客中的 Prepare to Install 部分。

    sudo wget -r --no-parent -A 'epel-release-*.rpm' https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/
    sudo rpm -Uvh dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-*.rpm
    sudo yum-config-manager --enable epel*
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-25
      • 2019-12-08
      • 2014-06-03
      • 1970-01-01
      • 2018-12-12
      • 2016-04-21
      • 2014-08-05
      • 2015-05-05
      相关资源
      最近更新 更多