🔰 Introduction In many containerized environments, it’s common to run Apache in one container and PHP-FPM in another.By default, an Apache container that serves only static files (HTML, CSS, JS) won’t execute PHP scripts because it lacks the PHP runtime. If you’ve started a separate PHP-FPM container, you can configure Apache to forward all .php…
Category: Docker
About Docker Command
Apache 整合 PHP-FPM 容器
🔰 前言 在容器化環境中,常見的架構是將 Apache 與 PHP-FPM 分開成兩個容器執行。Apache 容器負責靜態內容(HTML、CSS、JS)與 HTTP 請求處理,而 PHP-FPM 容器則負責 PHP 程式的執行。 若你的 Apache 容器目前僅能顯示靜態頁面(無法執行 PHP 程式),可以透過設定 Apache 的網站組態檔,將 .php 檔案交由 PHP-FPM 容器 處理。本文將說明整合步驟與注意事項。 🧩 環境假設 假設目前有以下環境: ⚙️ 步驟一:確認網路連線 首先確認 Apache 與 PHP-FPM 是否在同一個網路中: 如果未在同一網段,可手動加入: ⚙️ 步驟二:啟用 Apache 代理模組 在 Apache 容器中啟用以下模組: 啟用後重新啟動 Apache: ⚙️ 步驟三:修改 Apache 網站設定檔 編輯網站設定檔(例如 /etc/apache2/sites-available/000-default.conf),在 <VirtualHost> 區塊內加入以下設定: 設定說明:…
Docker Network Create
When creating a Docker network, you can specify a custom subnet and gateway using the docker network create command with the –subnet and –gateway parameters. 🧩 Example Command 🔍 Explanation Parameter Description –driver=bridge Specifies the network driver. The default is bridge. While optional, it’s good practice to include it explicitly. –subnet=172.24.0.0/16 Defines the IP subnet…
Docker 建立特定網段
建立Docker Network 時指定網段及Gateway 的指令。建立一個自訂的 Docker 網路,指定 subnet 與 gateway,可以用 docker network create 搭配 –subnet 與 –gateway 參數。 範例如下: 說明: –driver=bridge → 預設就是 bridge,可以省略,但建議寫明。–subnet=172.24.0.0/16 → 指定網段。–gateway=172.24.0.1 → 指定網路閘道。mail-network → 網路名稱。 建立好之後可以確認: 會看到類似: