# Certbot-免費的https證書
### 獲取SSL證書
理論上,我們自己也可以手動制作一個 SSL 安全證書,但是我們自己簽發的安全證書瀏覽器信任,所以我們需要被信任的證書授權中心( CA )簽發的安全證書。而一般的 SSL 安全證書簽發服務都需要付費,且價格昂貴,不過為了加快推廣 https 的普及, EEF 電子前哨基金會、 Mozilla 基金會和美國密歇根大學成立了一個公益組織叫 ISRG ( Internet Security Research Group ),這個組織從 2015 年開始推出了 Let’s Encrypt 免費證書。這個免費證書不僅免費,而且還相當好用,所以我們就可以利用 Let’s Encrypt 提供的免費證書部署 https 了。
### Let’s Encrypt
Let’s Encrypt提供了免費的證書申請服務,同時也提供了官方客戶端 [Certbot](https://certbot.eff.org/),打開首頁,就可以得到官方的安裝教程。官方教程給出了四種常用服務器和不同的Linux、Unix的安裝使用方案,可以說是十分的貼心了。

下面我將會介紹一個通用的安裝方案:
##### 1.獲取certbot-auto
~~~cpp
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
~~~
##### 2.生成證書
生成證書前需要停下nginx
~~~undefined
service nginx stop
~~~
~~~cpp
./certbot-auto certonly
~~~
根據提示,輸入相關資料后,如打印類似以下內容,即可在/etc/letsencrypt/archive目錄下得到證書文件。
如果不想一步一步走,也可以直接使用以下命令直接生成。注意xxx需要替換為自己的東西。
~~~cpp
./certbot-auto certonly --standalone --email xxx@xxx.com --agree-tos -d xxx.com -d www.xxx.com
~~~
xxx@xxx.com 填郵箱 xxx.com 目錄名稱 www.xxx.com 這是域名


##### 3.配置證書
Nginx中配置SSL證書的配置文件參考如下:
~~~bash
server {
listen 443 ssl;
server_name xxx.com;
location / {
# ....
}
ssl_certificate /etc/letsencrypt/live/xxx.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/xxx.com/privkey.pem;
}
server {
listen 80;
server_name xxx.com;
location / {
# ...
}
#如果需要把http強制轉換為https,需要配置以下內容
if ($host = xxx.com) {
#最好不要,會導致數據表丟失,post數據丟失,回調數據丟失
return 301 https://$host$request_uri;
}
}
~~~
配置完成后,啟動Nginx,瀏覽器中查看效果。
~~~undefined
service nginx start
~~~
~~~
##### 以后執行這個,自動更新
service nginx stop
certbot-auto renew
service nginx start
~~~
Upgrading certbot-auto 1.3.0 to 1.5.0...
Replacing certbot-auto...
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/xxx.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert not yet due for renewal
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/www.xxxxx.com-0001.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert not yet due for renewal
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/www.xxxxx.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator standalone, Installer None
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for ifreshuk.com
Waiting for verification...
Cleaning up challenges
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
new certificate deployed without reload, fullchain is
/etc/letsencrypt/live/www.xxxxx.com/fullchain.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The following certs are not due for renewal yet:
/etc/letsencrypt/live/xxxxxx.com/fullchain.pem expires on 2020-09-02 (skipped)
/etc/letsencrypt/live/www.xxxxxx.com-0001/fullchain.pem expires on 2020-09-30 (skipped)
Congratulations, all renewals succeeded. The following certs have been renewed:
/etc/letsencrypt/live/www.xxxxxx.com/fullchain.pem (success)
# 補充另外的一個網站申請:[https://freessl.cn/](https://freessl.cn/)
- PHP書寫規則
- 代碼縮進
- 大括號{ }書寫規則
- 變量賦值對齊
- if條件判斷規范
- 避免嵌入式賦值
- 函數和方法的注釋
- 項目規范
- 業務邏輯logic
- model模型
- 控制器
- view視圖
- 定制項目開發
- 接口輸出變量格式
- mysql設計規范
- 二維碼系列
- php 用phprqcode 生成簡單的二維碼
- 小程序二維碼
- 其他小工具
- 獲取單個漢字拼音首字母
- js 調起打印多出一張空白的問題?
- php 2張圖片合拼
- 判斷一個漢字可以等于1個字符,2個字符,3個字符
- 微信小程序獲取頁面路徑
- 小程序js、canvas實現矩形圓角、圓形頭像圖片
- php phpMailer 發送郵件(親測有效)
- 系統配置表
- php 用tcpdf 生成pdf
- PHP mkdir():創建目錄
- php 通過svg動態生成生成后綴圖標
- php 本地安裝SSL證書
- php 生成首字母頭像
- php 接口數據壓縮返回,減少帶寬
- PHP向二維數組多維數組追加相同元素
- php 指定時間戳上加上一天,一個月,一年的方法
- Spreadsheet 表格生成
- php 多維數組排序 多維數組按照某個字段排序
- php根據開始和結束時間獲取期間日期
- php 獲取本周、上周、本月、上月及指定時間所在周、月的起止時間
- php GeoIP2通過ip獲取國家和地區城市
- 奇葩報錯問題
- session賦值報錯
- 服務器配置lnmp
- 開啟mysql binglog 日志
- lnmp 開啟遠程訪問3306
- 開啟mysql 慢日志查詢
- 開通Liunx 3306 端口(遠程連接開放)
- 搭建lnmp
- liunx 多臺服務器搭建共享文件夾圖片文件夾
- liunx 操作命令1
- nginx專區
- 禁止外部ip訪問
- 強制跳轉到https
- mysql專區
- 版本5.7報錯 only_full_group_by
- 把同一張表的一個字段的內容復制到另一個字段里
- lnmp關閉嚴格模式
- mysql 兩張不同結構的表連表查詢,合并,并分頁,排序 教你如何實現UNION
- mysql 查詢一張表中某個字段不同狀態的數量統計
- mysql數據庫快速插入百萬條級別的測試數據
- MySQL EXPLAIN 詳解,可用EXPLAIN來分析優化數據庫sql語句
- mysql 三星索引
- mysql 返回數據排名查詢獲取排名的方法,親測有效
- mysql使用查詢出來的值并且更新update新的表報錯?叫你一招
- mysql 怎樣自定義in查詢操作排序
- mysql 百萬級別和千萬級數據分頁查詢性能優化
- mysql 查詢某個字段按照逗號分割返回
- mysql 用sql命令導入數據庫
- mysql 根據某個字段的值匹配替換某個值
- Mysql中分組后取最新的一條數據排序
- Certbot-免費的https證書
- session_start()報錯問題
- 文件大打不開?代碼實現分割
- windows服務器專區
- apache 突然重啟動不了
- windows 定時任務
- liunx專區
- liunx 定時器檢查php是否能訪問,重啟
- liunx 操作命令
- 定時器 tp5 命令行
- liunx查看端口是否開放
- liunx上傳或者下載本地文件
- 前端
- jq克隆html
- Jquery添加元素(append,prepend,after,before四種方法區別對比)
- 小程序switch樣式修改
- css div 里面模塊 平均展開
- 安全小學堂
- 驗證碼一次一碼
- 實戰thinkphp6
- 前言
- 中間件
- 開啟多語言
- RabbitMQ 專區
- 下載RabbitMQ
- ftp專區
- Linux安裝vsftpd及配置詳解
- 小程序欄目
- 微信小程序封裝統一接口請求api數據
- 云數據庫
- 小程序云開發更新云函數數組的某一項,并且某個是變量代替
- php面試總結
- Mysql面試
- PHP面試知識
- Thinkphp框架小知識
- fastadmin 文檔
- fastadmin js 渲染 動態下拉(SelectPage)組件
- fastadmin 列表搜索欄 支持三級聯動 地區選項
- fastadmin searchList組件自定義數據返回
- 開發工具
- phpstorm 一直在Indexing,一直加載索引,無法正常使用
- PHP專區
- session 工作流程
- Redis
- php redis 基本操作
- SourceTree 3.3.9跳過注冊安裝
- composer 專區
- 手把手教你寫一個composer包
- freessl證書申請