国产成人精品无码青草_亚洲国产美女精品久久久久∴_欧美人与鲁交大毛片免费_国产果冻豆传媒麻婆精东

15158846557 在線咨詢 在線咨詢
15158846557 在線咨詢
所在位置: 首頁(yè) > 營(yíng)銷(xiāo)資訊 > 網(wǎng)站運(yùn)營(yíng) > 我不是網(wǎng)管 - RHEL 8上使用Let s Encrypt證書(shū)保護(hù) Apache服務(wù)器

我不是網(wǎng)管 - RHEL 8上使用Let s Encrypt證書(shū)保護(hù) Apache服務(wù)器

時(shí)間:2023-06-29 11:06:01 | 來(lái)源:網(wǎng)站運(yùn)營(yíng)

時(shí)間:2023-06-29 11:06:01 來(lái)源:網(wǎng)站運(yùn)營(yíng)

我不是網(wǎng)管 - RHEL 8上使用Let s Encrypt證書(shū)保護(hù) Apache服務(wù)器:在一個(gè)不斷受到安全威脅的網(wǎng)絡(luò)世界中,確保您的 Web 服務(wù)器安全是最重要的事情。保護(hù)您的 Web 服務(wù)器的方法之一是使用 SSL/TLS 證書(shū)在網(wǎng)站上實(shí)現(xiàn) HTTPS 協(xié)議。SSL/TLS 證書(shū)不僅通過(guò)對(duì) Web 服務(wù)器和用戶瀏覽器之間交換的信息進(jìn)行加密來(lái)確保您的網(wǎng)站,還可以幫助 Google 排名。

在本指南中,您將學(xué)習(xí)在 RHEL 8 上如何使用 Let's Encrypt SSL/TLS 來(lái)保護(hù) Apache(HTTP)Web 服務(wù)器。

必備條件

(1) 安裝 Apache

第一步是安裝 Apache web 服務(wù)器。您可以使用如下所示的 DNF 包管理器來(lái)安裝它。

$ sudo dnf install -y httpd安裝完成后,啟動(dòng) Apache web 服務(wù)器并使其在引導(dǎo)時(shí)啟動(dòng)。

$ sudo systemctl start httpd$ sudo systemctl enable httpd要驗(yàn)證 Apache 是否正在運(yùn)行,請(qǐng)執(zhí)行以下命令

$ sudo systemctl status httpd


Apache-Server-Status-RHEL



注意: 如果防火墻正在運(yùn)行,則允許以下 Apache 端口在防火墻中運(yùn)行

$ sudo firewall-cmd --add-port=80/tcp --permanent$ sudo firewall-cmd --add-port=443/tcp –permanent$ sudo firewall-cmd --realod現(xiàn)在,你可以轉(zhuǎn)到你的瀏覽器,輸入你的域名訪問(wèn)。




Default-Apache-Web-Page-rhel8



(2) 安裝 Certbot

Certbot 是一個(gè)易于使用的開(kāi)源客戶端,由 EFF (Electronic Frontier Foundation) 維護(hù)。它從 Lets Encrypt 獲取 TLS 證書(shū)并將其部署到 web 服務(wù)器。通過(guò)這樣做,它消除了使用 TLS 證書(shū)實(shí)現(xiàn) HTTPS 協(xié)議的麻煩和痛苦。

要安裝 Certbot 和相關(guān)的包,首先要啟用 EPEL (Extra Packages for Enterprise Linux)

$ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y接下來(lái),按如下方法安裝 certbot 和 mod ssl 包

$ sudo dnf install certbot python3-certbot-apache mod_ssl


Install-certbot-python2-package-rhel8



(3) 創(chuàng)建一個(gè) Apache 虛擬主機(jī)文件

虛擬主機(jī)使得在一個(gè) web 服務(wù)器上托管多個(gè)域成為可能。

第一步是在 Document 根目錄中創(chuàng)建一個(gè)目錄,所有的網(wǎng)站文件都將進(jìn)入該目錄

$ sudo mkdir -p /var/www/linuxtechgeek.info/html設(shè)置目錄歸屬為 Apache 用戶

$ sudo chown -R apache:apache /var/www/linuxtechgeek.info/html請(qǐng)確保按所示設(shè)置目錄權(quán)限

$ sudo chmod -R 755 /var/www接著在 /etc/httpd/conf.d 目錄中創(chuàng)建虛擬主機(jī)文件

$ sudo vi /etc/httpd/conf.d/linuxtechgeek.info.conf粘貼下面的內(nèi)容,注意使用自己的域名

<virtualhost *:80>ServerName linuxtechgeek.infoServerAlias www.linuxtechgeek.infoDocumentRoot /var/www/linuxtechgeek.info/htmlErrorLog /var/log/httpd/linuxtechgeek.info-error.logCustomLog /var/log/httpd/linuxtechgeek.info-access.log combined</virtualhost>保存并退出 VirtualHost 文件

為了測(cè)試虛擬主機(jī)是否正在工作,我們將在網(wǎng)站目錄中創(chuàng)建一個(gè)示例 HTML 文件。

$ sudo vi /var/www/linuxtechgeek.info/html/index.html粘貼以下示例內(nèi)容,您也可以根據(jù)自己的喜好隨意修改它。

<!DOCTYPE html><html> <body> <h1> Welcome to Linuxtechi virtualhost </h1> </body></html>保存并退出 HTML 文件。要保存所做的所有更改,請(qǐng)重新啟動(dòng) Apache web 服務(wù)器。

$ sudo systemctl restart httpd再次訪問(wèn)您的域名,您將看到剛剛配置的定制 HTML 頁(yè)面,而不是默認(rèn)的 Apache 歡迎頁(yè)面。




Custom-Apache-WebPage-RHEL8



(4) 使用 Let’s Encrypt 證書(shū)保護(hù) Apache

最后一步是獲取并部署 Let’s Encrypt 證書(shū),運(yùn)行以下命令

$ sudo certbot --apacheWhen the command is executed, certbot will walk you through a series of prompts. You will be prompted for your email address and be required to agree to the Terms and conditions. You will also be asked whether you would like to receive periodic emails about EFF news, and campaigns about digital freedom.

當(dāng)執(zhí)行該命令時(shí),certbot 將引導(dǎo)您完成一系列提示。系統(tǒng)會(huì)提示您輸入您的電子郵件地址,并要求您同意本條款和條件。你還會(huì)被問(wèn)到是否愿意定期收到 EFF 的新聞和活動(dòng)的電子郵件。




Certbot-Apache-Command-Output-RHEL



當(dāng)提示要激活 HTTPS 的名稱時(shí),只需按 ENTER 將證書(shū)應(yīng)用到所有提供的域。

Certbot will proceed to fetch the TLS certificate from Let’s Encrypt and implement it on your web server. Certbot will then print the path where the certificate and key have been saved as well as the deployment path of the certificate for your domains.

Certbot 將繼續(xù)從 Let s Encrypt 獲取 TLS 證書(shū),并部署在您的 web 服務(wù)器上。然后,Certbot 將打印保存證書(shū)和密鑰的路徑以及域證書(shū)的部署路徑。




Lets-encrypt-ssl-certs-certbot-apache



要驗(yàn)證 Let’s encrypt 已成功部署,請(qǐng)刷新瀏覽器。您會(huì)注意到在 URL 欄開(kāi)始處出現(xiàn)了一個(gè)掛鎖圖標(biāo),表明站點(diǎn)已成功加密。




Access-Apache-over-ssl-rhel



您可以單擊掛鎖圖標(biāo)了解更多詳細(xì)信息




Apache-WebPage-Domain-Info
此外,您可以在SSL Labs 上進(jìn)行 SSL 測(cè)試,以數(shù)字驗(yàn)證您的證書(shū)。如果一切順利,您應(yīng)該獲得一個(gè)等級(jí)A的成績(jī)。




Test-Apache-SSL-Certs-On-SSL-Labs



(5) Let’s Encrypt 證書(shū)續(xù)訂

Let’s Encrypt 證書(shū)有效期只有 90 天,在證書(shū)到期前幾周,您通常會(huì)收到 EFF 的通知,通知您證書(shū)即將到期,需要更新您的證書(shū)。

當(dāng)需要手動(dòng)更新證書(shū)時(shí),使用該命令

$ sudo certbot renew當(dāng)需要模擬證書(shū)更新時(shí),使用該命令

$ sudo certbot renew --dry-run這只是模擬實(shí)際的證書(shū)更新,不執(zhí)行任何操作。




Renew-Apache-Certbot-SSL-Certs



要自動(dòng)更新證書(shū),請(qǐng)打開(kāi) crontab 文件

$ crontab -e指定下面的 cron 作業(yè),它將在每個(gè)午夜運(yùn)行。

0 0 * * * /usr/bin/certbot renew > /dev/null 2>&1

我的開(kāi)源項(xiàng)目




酷瓜云課堂-開(kāi)源網(wǎng)校系統(tǒng)



關(guān)鍵詞:證書(shū),保護(hù),服務(wù),使用

74
73
25
news

版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。

為了最佳展示效果,本站不支持IE9及以下版本的瀏覽器,建議您使用谷歌Chrome瀏覽器。 點(diǎn)擊下載Chrome瀏覽器
關(guān)閉