1. 安裝套件 sudo dnf update -y sudo dnf install -y nginx mariadb105-server \ php8.4 php8.4-fpm php8.4-mysqlnd \ php8.4-gd php8.4-mbstring php8.4-xml \ php8.4-intl php8.4-zip php8.4-cli 2. 啟動服務 sudo systemctl enable --now nginx sudo systemctl enable --now php-fpm sudo systemctl enable --now mariadb 3. 建立 WordPress 資料庫 sudo mysql CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'admin'@'localhost' IDENTIFIED BY 'rqw10o'; GRANT ALL PRIVILEGES ON wordpress.* TO 'admin'@'localhost'; FLUSH PRIVILEGES; EXIT; 4. 下載及安裝 WordPress cd /tmp curl -LO https://wordpress.org/latest.tar.gz tar -xzf latest.tar.gz sudo mkdir -p /var/www/html sudo cp -a wordpress/. /var/www/html/ sudo chown -R nginx:nginx /var/www/html 5. 設定 Nginx sudo tee /etc/nginx/conf.d/wordpress.conf > /dev/null <<'EOF' server { listen 80; server_name _; root /var/www/html; index index.php index.html; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass unix:/run/php-fpm/www.sock; } location ~ /\. { deny all; } } EOF sudo nginx -t sudo systemctl reload nginx 6. 設定 WordPress 資料庫連線 cd /var/www/html sudo cp wp-config-sample.php wp-config.php sudo vi wp-config.php 修改以下四個設定: define('DB_NAME', 'wordpress'); define('DB_USER', 'wpuser'); define('DB_PASSWORD', '你的資料庫密碼'); define('DB_HOST', 'localhost'); 7. 驗證服務 sudo systemctl status nginx sudo systemctl status php-fpm sudo systemctl status mariadb curl -I http://localhost/ 8. 移除80PORT衝突 sudo vi /etc/nginx/nginx.conf 找到第 44 行附近: server { listen 80; server_name _; root /usr/share/nginx/html; 將整個預設 server { ... } 區塊註解或移除。 9. 修改設定 cloudfront 快取跟請求要改 Managed-CachingDisabled Managed-AllViewerExceptHostHeader 入站要改成Https sudo vi /var/www/html/wp-config.php /* Add any custom values between this line and the "stop editing" line. */ define('WP_HOME', 'https://ab571.com'); define('WP_SITEURL', 'https://ab571.com'); if ( isset($_SERVER['HTTP_CLOUDFRONT_FORWARDED_PROTO']) && $_SERVER['HTTP_CLOUDFRONT_FORWARDED_PROTO'] === 'https' ) { $_SERVER['HTTPS'] = 'on'; } /* That's all, stop editing! Happy publishing. */ 10. 下載繁體中文 cd /var/www/html curl -fL \ "https://downloads.wordpress.org/translation/core/7.0.7/zh_TW.zip" \ -o /tmp/zh_TW.zip sudo unzip -o /tmp/zh_TW.zip -d /var/www/html/wp-content/languages/ 11. 無法存取目錄,要讓nginx跟apache相同權限 sudo mkdir -p /var/www/html/wp-content/uploads sudo chown -R nginx:apache /var/www/html/wp-content/uploads sudo chmod -R 775 /var/www/html/wp-content/uploads