Centos8 腾讯云 安装 certbot Nginx 通过 certbot 为网站自动配置 SSL 证书并续期

摘要:
//certbot.eff.org/lets-encrypt/centoshel7-nginx.htmlhttps:

centos8

https://certbot.eff.org/lets-encrypt/centosrhel8-nginx.html

centos 7

https://certbot.eff.org/lets-encrypt/centosrhel7-nginx.html

https://blog.51cto.com/wzlinux/2385116

网上很多文章写了各种方法,官网上有解释,

其实各种方式都可以。Snap、certbot-auto、redhat下面(sudo dnf install)都可以。选一个即可。具体区别可以看下面的的英文。

Certbot-Auto

The certbot-auto wrapper script installs Certbot, obtaining some dependencies from your web server OS and putting others in a python virtual environment. You can download and run it as follows:

我在这边参考 https://blog.51cto.com/wzlinux/2385116 出现无法获取python2-certbot-nginx的问题。换到Snap来安装。还是看官网的介绍来把。比较顺利一点。

snap install 慢的终极解决办法

https://blog.csdn.net/LingHuChong20/article/details/104784160/

https://certbot.eff.org/lets-encrypt/centosrhel8-nginx.html

Alternate installation methods

If you are offline or your operating system doesn’t provide a package, you can use an alternate method for installing certbot.

Snap

Most modern Linux distributions (basically any that use systemd) can install Certbot packaged as a snap. Snaps are available for x86_64, ARMv7 and ARMv8 architectures. The Certbot snap provides an easy way to ensure you have the latest version of Certbot with features like automated certificate renewal preconfigured.

You can find instructions for installing the Certbot snap at https://certbot.eff.org/instructions by selecting your server software and then choosing “snapd” in the “System” dropdown menu. (You should select “snapd” regardless of your operating system, as our instructions are the same across all systems.)

Certbot-Auto

The certbot-auto wrapper script installs Certbot, obtaining some dependencies from your web server OS and putting others in a python virtual environment. You can download and run it as follows:

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
/usr/local/bin/certbot-auto --help

To remove certbot-auto, just delete it and the files it places under /opt/eff.org, along with any cronjob or systemd timer you may have created.

To check the integrity of the certbot-auto script, you can use these steps:

user@webserver:~$ wget -N https://dl.eff.org/certbot-auto.asc
user@webserver:~$ gpg2 --keyserver pool.sks-keyservers.net --recv-key A2CFB51FA275A7286234E7B24D17C995CD9775F2
user@webserver:~$ gpg2 --trusted-key 4D17C995CD9775F2 --verify certbot-auto.asc /usr/local/bin/certbot-auto

The output of the last command should look something like:

gpg: Signature made Wed 02 May 2018 05:29:12 AM IST
gpg:                using RSA key A2CFB51FA275A7286234E7B24D17C995CD9775F2
gpg: key 4D17C995CD9775F2 marked as ultimately trusted
gpg: checking the trustdb
gpg: marginals needed: 3  completes needed: 1  trust model: pgp
gpg: depth: 0  valid:   2  signed:   2  trust: 0-, 0q, 0n, 0m, 0f, 2u
gpg: depth: 1  valid:   2  signed:   0  trust: 2-, 0q, 0n, 0m, 0f, 0u
gpg: next trustdb check due at 2027-11-22
gpg: Good signature from "Let's Encrypt Client Team <letsencrypt-client@eff.org>" [ultimate]

The certbot-auto command updates to the latest client release automatically. Since certbot-auto is a wrapper to certbot, it accepts exactly the same command line flags and arguments. For more information, see Certbot command-line options.

For full command line help, you can type:

/usr/local/bin/certbot-auto --help all

Problems with Python virtual environment

On a low memory system such as VPS with less than 512MB of RAM, the required dependencies of Certbot will fail to build. This can be identified if the pip outputs contains something like internal compiler error: Killed (program cc1). You can workaround this restriction by creating a temporary swapfile:

user@webserver:~$ sudo fallocate -l 1G /tmp/swapfile
user@webserver:~$ sudo chmod 600 /tmp/swapfile
user@webserver:~$ sudo mkswap /tmp/swapfile
user@webserver:~$ sudo swapon /tmp/swapfile

Disable and remove the swapfile once the virtual environment is constructed:

user@webserver:~$ sudo swapoff /tmp/swapfile
user@webserver:~$ sudo rm /tmp/swapfile

Running with Docker

Docker is an amazingly simple and quick way to obtain a certificate. However, this mode of operation is unable to install certificates or configure your webserver, because our installer plugins cannot reach your webserver from inside the Docker container.

Most users should use the instructions at certbot.eff.org. You should only use Docker if you are sure you know what you are doing and have a good reason to do so.

You should definitely read the Where are my certificates? section, in order to know how to manage the certs manually. Our ciphersuites page provides some information about recommended ciphersuites. If none of these make much sense to you, you should definitely use the installation method recommended for your system at certbot.eff.org, which enables you to use installer plugins that cover both of those hard topics.

If you’re still not convinced and have decided to use this method, from the server that the domain you’re requesting a certficate for resolves to, install Docker, then issue a command like the one found below. If you are using Certbot with the Standalone plugin, you will need to make the port it uses accessible from outside of the container by including something like -p 80:80 or -p 443:443 on the command line before certbot/certbot.

sudo docker run -it --rm --name certbot 
            -v "/etc/letsencrypt:/etc/letsencrypt" 
            -v "/var/lib/letsencrypt:/var/lib/letsencrypt" 
            certbot/certbot certonly

Running Certbot with the certonly command will obtain a certificate and place it in the directory /etc/letsencrypt/live on your system. Because Certonly cannot install the certificate from within Docker, you must install the certificate manually according to the procedure recommended by the provider of your webserver.

There are also Docker images for each of Certbot’s DNS plugins available at https://hub.docker.com/u/certbot which automate doing domain validation over DNS for popular providers. To use one, just replace certbot/certbot in the command above with the name of the image you want to use. For example, to use Certbot’s plugin for Amazon Route 53, you’d use certbot/dns-route53. You may also need to add flags to Certbot and/or mount additional directories to provide access to your DNS API credentials as specified in the DNS plugin documentation.

For more information about the layout of the /etc/letsencrypt directory, see Where are my certificates?.

Operating System Packages

Arch Linux

sudo pacman -S certbot

Debian

If you run Debian Buster or Debian testing/Sid, you can easily install certbot packages through commands like:

sudo apt-get update
sudo apt-get install certbot

If you run Debian Stretch, we recommend you use the packages in Debian backports repository. First you’ll have to follow the instructions at https://backports.debian.org/Instructions/ to enable the Stretch backports repo, if you have not already done so. Then run:

sudo apt-get install certbot -t stretch-backports

In all of these cases, there also packages available to help Certbot integrate with Apache, nginx, or various DNS services. If you are using Apache or nginx, we strongly recommend that you install the python-certbot-apache or python-certbot-nginx package so that Certbot can fully automate HTTPS configuration for your server. A full list of these packages can be found through a command like:

apt search 'python-certbot*'

They can be installed by running the same installation command above but replacing certbot with the name of the desired package.

Ubuntu

If you run Ubuntu, certbot can be installed using:

sudo apt-get install certbot

Optionally to install the Certbot Apache plugin, you can use:

sudo apt-get install python-certbot-apache

Fedora

sudo dnf install certbot python2-certbot-apache

FreeBSD

  • Port: cd /usr/ports/security/py-certbot && make install clean
  • Package: pkg install py27-certbot

Gentoo

The official Certbot client is available in Gentoo Portage. From the official Certbot plugins, three of them are also available in Portage. They need to be installed separately if you require their functionality.

emerge -av app-crypt/certbot
emerge -av app-crypt/certbot-apache
emerge -av app-crypt/certbot-nginx
emerge -av app-crypt/certbot-dns-nsone

Note

The app-crypt/certbot-dns-nsone package has a different maintainer than the other packages and can lag behind in version.

NetBSD

  • Build from source: cd /usr/pkgsrc/security/py-certbot && make install clean
  • Install pre-compiled package: pkg_add py27-certbot

OpenBSD

  • Port: cd /usr/ports/security/letsencrypt/client && make install clean
  • Package: pkg_add letsencrypt

Other Operating Systems

OS packaging is an ongoing effort. If you’d like to package Certbot for your distribution of choice please have a look at the Packaging Guide.

免责声明:文章转载自《Centos8 腾讯云 安装 certbot Nginx 通过 certbot 为网站自动配置 SSL 证书并续期》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇java web 之 web.xml篇SpringMVC拦截器详解下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

XScreenSaver强大的锁屏工具

source install:  https://www.jwz.org/xscreensaver/   XScreenSaver     Related articles DPMS Xresources List of applications#Screen lockers XScreenSaver is a screen saver and...

tp5+双语言

1.配置 // 是否开启多语言 'lang_switch_on' => true, //多语言列表 'lang_list' => ['id-id','en-us'], // 默认语言 'default_lang' => 'id-id', 2.控制器 &l...

Kubernetes 网络排错指南

本文介绍各种常见的网络问题以及排错方法,包括 Pod 访问异常、Service 访问异常以及网络安全策略异常等。 说到 Kubernetes 的网络,其实无非就是以下三种情况之一 Pod 访问容器外部网络 从容器外部访问 Pod 网络 Pod 之间相互访问 当然,以上每种情况还都分别包括本地访问和跨主机访问两种场景,并且一般情况下都是通过 Servic...

[笔记]Cucumber在windows下的安装

1.下载安装Ruby 安装Cucumber要用到gem,gem是Ruby程序管理工具,类似于linux中的apt-get。所以要在Windows中安装好Ruby1.9.2的版本相对稳定些,在这里可以下载Ruby,Windows的安装包一路Next就可以了,安装完成后以cmd输入:ruby -v查看版本,如果提示不是内部命令,着加系统环境变量。 升级gems...

Elasticsearch集群优化实战

版本配置: ES版本:6.2.4 OS内存64G。 一、安装部署: 1.ES jvm内存31G,预留一半的物理内存给文件系统缓存(file system cache)。 2.禁止内存交换: 修改/etc/sysctl.conf 中 vm.swappiness = 1 elasticsearch.yml中,设置这个:bootstrap.mlockall:tr...

Spring之Bean管理------注解方式

编写测试类 1,编写相关的类 public interface UserDao { public void sayHello(); } public class UserDaoImpl implements UserDao { @Override public void sayHello() { System.out.println("Hello Spri...