一、系統環境
作業系統:macOS ✅
Web Server:Apache(macOS 內建) ✅
PHP 版本:PHP 8.4(Homebrew) ✅
PHP 執行模式:PHP-FPM(port 9000) ✅
MySQL 版本:MySQL 9.6.0(Homebrew) ✅
二、網站設定
Virtual Host
設定檔路徑:/private/etc/apache2/sites-available/demo.tw.conf ✅
網站網域:demo.tw ✅
網站根目錄:/Library/WebServer/Documents/demo ✅
hosts 設定
hosts 檔案:/etc/hosts ✅
對應設定:127.0.0.1 demo.tw ✅
📝 原本指向區網 IP 10.10.168.140,已修正為 127.0.0.1
三、WordPress 設定
安裝目錄:/Library/WebServer/Documents/demo ✅
設定檔:wp-config.php(已建立) ✅
安裝網址:http://demo.tw/wp-admin/install.php ✅
Table Prefix:wp_(預設)
Secret Keys:已由 WordPress.org 自動產生 ✅
四、資料庫設定(wp-config.php)
DB_NAME:demo ✅
DB_USER:demo ✅
DB_PASSWORD:(已設定)
DB_HOST:localhost ✅
DB_CHARSET:utf8mb4 ✅
📝 MySQL root 帳號與 demo 使用者均已設定完成
五、Apache 設定重點
PHP 模組
PHP Handler:SetHandler “proxy:fcgi://127.0.0.1:9000” ✅
設定檔:/etc/apache2/httpd.conf ✅
📝 原本使用 php7_module(已廢棄),改為 PHP-FPM via FastCGI proxy
Directory 設定(demo.tw.conf)
AllowOverride:All(支援 .htaccess) ✅
Options:FollowSymLinks MultiViews ✅
六、服務啟動指令
MySQL 啟動:mysql.server start
MySQL 停止:mysql.server stop
PHP-FPM 啟動:brew services start php
PHP-FPM 停止:brew services stop php
Apache 啟動:sudo apachectl start
Apache 停止:sudo apachectl stop
Apache 重啟:sudo apachectl restart
七、安裝過程問題排除紀錄
問題 1:MySQL 無法啟動 MySQL 8.3.0 依賴 icu4c@74,但系統為 icu4c@78
解決方案:升級 MySQL 至 9.6.0(brew upgrade mysql)
問題 2:MySQL 升級後仍無法啟動 8.3.0 → 9.6.0 不支援直接升級(需經 8.4 LTS)
解決方案:重置 data directory(mysqld –initialize-insecure –user=bigd)
問題 3:PHP 無法執行 httpd.conf 使用已廢棄的 php7_module,且 LoadModule 被註解
解決方案:改用 PHP-FPM 8.4,設定 FastCGI proxy 至 127.0.0.1:9000
問題 4:demo.tw 無法連線 /etc/hosts 指向舊區網 IP 10.10.168.140
解決方案:修正為 127.0.0.1
八、完成確認
✅ MySQL 9.6.0 啟動
✅ PHP-FPM 8.4 啟動(port 9000)
✅ Apache 啟動,PHP 可執行
✅ demo 資料庫 + 使用者建立
✅ wp-config.php 設定完成
✅ demo.tw → 127.0.0.1(hosts)
✅ Vhost demo.tw 指向正確目錄
✅ http://demo.tw/wp-admin/install.php WordPress 安裝頁面可存取