搜尋
首頁web前端前端問答ghost nodejs 部署

隨著 Node.js 變得越來越流行,越來越多的開發者開始使用它來創建後端應用程式。 Ghost 是一個基於 Node.js 的開源部落格平台,它使用了許多流行的 Node.js 技術和函式庫來幫助用戶創建美觀而功能豐富的部落格。

本文將向您展示如何在 Ghost 上託管一個 Node.js 應用程序,以及如何為其配置自訂網域和 SSL 憑證。

步驟 1:選擇雲端伺服器

首先,您需要選擇一款雲端伺服器來託管 Ghost 應用程式。市場上有許多雲端伺服器供應商,如 AWS、DigitalOcean 和 Linode 等。本文將以 DigitalOcean 為例進行說明。

步驟 2:建立虛擬機器

在 DigitalOcean 上建立一個虛擬機器很簡單。請依照下列步驟操作:

  1. 登入您的 DigitalOcean 帳戶。
  2. 在控制台頁面上,按一下「Create Droplet」。
  3. 選擇您的作業系統、計費計畫和資料中心位置。在這個例子中,我們將選擇 Ubuntu 18.04、Standard、SFO2。
  4. 選擇您的 SSH 金鑰或建立一個新的 SSH 金鑰。
  5. 點選「Create Droplet」按鈕。

DigitalOcean 將會為您建立並啟動一個全新的虛擬機器。

步驟 3:安裝 Node.js 和 Ghost

一旦您的虛擬機器處於活動狀態,您可以使用 SSH 連接到該虛擬機器並安裝 Node.js 和 Ghost。

  1. 使用 SSH 登入您的虛擬機器。
  2. 更新軟體包清單並升級所有已安裝的軟體包:

    sudo apt update
    sudo apt upgrade
  3. #安裝Node.js:

    curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
    sudo apt-get install -y nodejs
  4. 下載Ghost 並解壓縮:

    curl -L https://ghost.org/zip/ghost-latest.zip -o ghost-latest.zip
    unzip -uo ghost-latest.zip -d ghost
  5. 在Ghost 目錄中安裝相依性:

    cd ghost
    npm install --production
  6. 執行Ghost:

    npm start --production

如果一切正常的話,您可以在瀏覽器中輸入伺服器的IP 位址Ghost 的預設連接埠2368,查看出現了Ghost 的安裝頁面。

步驟 4:設定自訂網域名稱和 SSL 憑證

預設情況下,Ghost 伺服器只能透過 IP 位址存取。如果您想為 Ghost 應用程式設定自訂網域和 SSL 證書,則必須執行下列步驟。

  1. 安裝 Nginx 作為 Ghost 的反向代理伺服器。

    sudo apt-get install nginx
  2. 建立 Nginx 設定檔:

    sudo nano /etc/nginx/sites-available/ghost

    然後,輸入以下內容:

    server {
        listen 80;
        listen [::]:80;
        server_name your_domain.com;
    
        location / {
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://127.0.0.1:2368;
        }
    }

    這個設定檔將允許 Nginx 作為 Ghost 的網關。請注意將 your_domain.com 替換為您自己的網域。

  3. 讓Nginx 知道該設定檔的存在:

    sudo ln -s /etc/nginx/sites-available/ghost /etc/nginx/sites-enabled/
  4. 重新啟動Nginx 服務:

    sudo service nginx restart
  5. #下載SSL 憑證

    1. 使用Letsencrypt Certbot 來申請憑證。在您的SSH 終端機中,執行以下命令:

      sudo apt install certbot python3-certbot-nginx
    2. 然後,啟用該憑證:

      sudo certbot --nginx

      該命令將使用Nginx 設定檔中指定的網域名稱來給您的Ghost 應用程式產生SSL 憑證。

  6. 啟用 HTTPS

    一旦您的 SSL 憑證啟用並驗證成功,您就可以設定 Ghost 應用程式只在 HTTPS 上執行。

    1. 先關閉 Ghost:

      npm stop --production
    2. 開啟 Ghost 設定檔 config.production.json。
    3. 在「server」部分新增以下內容:

      "url": "https://your_domain.com",
      "server": {
          "port": 2368,
          "host": "127.0.0.1"
      },
      "ssl": {
          "force": true
      }
    4. #重新啟動Ghost:

      npm start --production

########################################################## #####現在,您的Ghost 應用程式已經在自訂網域和HTTPS 上運行。 ######結論######恭喜!透過本文的介紹,您已經知道如何在 Ghost 上託管一個 Node.js 應用程式並配置自訂網域和 SSL 憑證。這些步驟也可以用於託管任何其他的 Node.js 應用程式。 ###

以上是ghost nodejs 部署的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
反應的局限性是什麼?反應的局限性是什麼?May 02, 2025 am 12:26 AM

Include:1)AsteeplearningCurvedUetoItsVasteCosystem,2)SeochallengesWithClient-SiderEndering,3)潛在的PersperformanceissuesInsuesInlArgeApplications,4)ComplexStateStateManagementAsappsgrow和5)TheneedtokeEedtokeEedtokeEppwithitsrapideDrapidevoltolution.thereedtokeEppectortorservolution.thereedthersrapidevolution.ththesefactorsshesssheou

React的學習曲線:新開發人員的挑戰React的學習曲線:新開發人員的挑戰May 02, 2025 am 12:24 AM

reactischallengingforbeginnersduetoitssteplearningcurveandparadigmshifttocoment oparchitecent.1)startwithofficialdocumentationforasolidFoundation.2)了解jsxandhowtoembedjavascriptwithinit.3)

為React中的動態列表生成穩定且獨特的鍵為React中的動態列表生成穩定且獨特的鍵May 02, 2025 am 12:22 AM

ThecorechallengeingeneratingstableanduniquekeysfordynamiclistsinReactisensuringconsistentidentifiersacrossre-rendersforefficientDOMupdates.1)Usenaturalkeyswhenpossible,astheyarereliableifuniqueandstable.2)Generatesynthetickeysbasedonmultipleattribute

JavaScript疲勞:與React及其工具保持最新JavaScript疲勞:與React及其工具保持最新May 02, 2025 am 12:19 AM

javascriptfatigueinrectismanagbaiblewithstrategiesLike just just in-timelearninganning and CuratedInformationsources.1)學習whatyouneedwhenyouneedit

使用USESTATE()掛鉤的測試組件使用USESTATE()掛鉤的測試組件May 02, 2025 am 12:13 AM

tateractComponents通過theusestatehook,使用jestandReaCtTestingLibraryToSigulationsimintionsandIntractions and verifyStateChangesInTheUI.1)underthecomponentAndComponentAndComponentAndConconentAndCheckInitialState.2)模擬useruseruserusertactionslikeclicksorformsorformsormissions.3)

React中的鑰匙:深入研究性能優化技術React中的鑰匙:深入研究性能優化技術May 01, 2025 am 12:25 AM

KeysinreactarecrucialforopTimizingPerformanceByingIneFefitedListupDates.1)useKeyStoIndentifyAndTrackListelements.2)避免使用ArrayIndi​​cesasKeystopreventperformansissues.3)ChooSestableIdentifierslikeIdentifierSlikeItem.idtomaintainAinainCommaintOnconMaintOmentStateAteanDimpperperFermerfermperfermerformperfermerformfermerformfermerformfermerment.ChosestopReventPerformissues.3)

反應中的鍵是什麼?反應中的鍵是什麼?May 01, 2025 am 12:25 AM

ReactKeySareUniqueIdentifiers usedwhenrenderingListstoimprovereConciliation效率。 1)heelPreactrackChangesInListItems,2)使用StableanDuniqueIdentifiersLikeItifiersLikeItemidSisRecumended,3)避免使用ArrayIndi​​cesaskeyindicesaskeystopreventopReventOpReventSissUseSuseSuseWithReRefers和4)

反應中獨特鍵的重要性:避免常見的陷阱反應中獨特鍵的重要性:避免常見的陷阱May 01, 2025 am 12:19 AM

獨特的keysarecrucialinreactforoptimizingRendering和MaintainingComponentStateTegrity.1)useanaturalAlaluniqueIdentifierFromyourDataiFabable.2)ifnonaturalalientedifierexistsistsists,generateauniqueKeyniqueKeyKeyLiquekeyperaliqeyAliqueLiqueAlighatiSaliqueLiberaryLlikikeuuId.3)deversearrayIndi​​ceSaskeyseSecialIndiceSeasseAsialIndiceAseAsialIndiceAsiall

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

VSCode Windows 64位元 下載

VSCode Windows 64位元 下載

微軟推出的免費、功能強大的一款IDE編輯器

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!

MantisBT

MantisBT

Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用