You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于Alpine Linux的PHP-FPM 8.3 WordPress Docker应用无法加载内容

WordPress迁移到Alpine Linux环境后空白页问题排查

环境与配置

选用基于Alpine Linux的trafex/wordpress镜像替代官方Apache版,通过Jenkins流水线构建部署,相关配置如下:

Dockerfile

FROM trafex/wordpress:latest

# Copy built files to WordPress file system
COPY default/ /usr/src/wordpress/wp-content/themes/default/
COPY wp-install-plugins.sh /usr/local/bin/

# Update package lists and install MySQL client and net-tools
RUN apk add --no-cache mysql-client net-tools

# Optionally, clean up package cache
RUN rm -rf /var/cache/apk/*

docker-compose.yml

version: '3.1'
services:
  wordpress:
    image: myregistry:5000/myapp:current
    container_name: myapp_wordpress_1
    networks:
      - reverse-proxy
    restart: always
    hostname: myapp-dev.mydomain.io
    ports:
      - "8123:80"
    environment:
      DB_HOST: WP_HOST
      DB_USER: WP_DB_USER
      DB_PASSWORD: WP_DB_PWD
      DB_NAME: WPDB_NAME
      VIRTUAL_HOST: myapp-dev.mydomain.io
      FS_METHOD: direct
      WP_DEBUG: "true"
      WP_DEBUG_DISPLAY: "true"
      VIRTUAL_PORT: 80
    volumes:
      - /home/deploy/jenkins/myapp/uploads:/var/www/wp-content/uploads
      - ${WORKSPACE}/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
      - ${WORKSPACE}/wp-install-plugins.sh:/var/www/wp-install-plugins.sh
      - ${WORKSPACE}/wp-config.php:/var/www/wp-config.php
networks:
  reverse-proxy:
    external:
      name: reverse-proxy

wp-config.php

<?php
define( 'DB_NAME', 'myapp_dev' );
define( 'DB_USER', 'myapp_dev' );
define( 'DB_PASSWORD', 'myapp_password' );
define( 'DB_HOST', 'my_app_db.io:3306' );

define( 'DB_CHARSET', 'utf8' );
define( 'DB_COLLATE', '' );

$table_prefix = 'wp_';

define( 'WP_DEBUG', false );

if ( ! defined( 'ABSPATH' ) ) {
    define( 'ABSPATH', dirname( __FILE__ ) . '/' );
}

require_once ABSPATH . 'wp-settings.php';

wp-install-plugins.sh

#!/bin/bash

wp core download
wp core update --allow-root
wp core update-db --allow-root
wp site list --field=url | xargs -n1 -I % wp --url=% option update timezone_string 'America/New_York' --allow-root
wp plugin delete hello akismet --allow-root
wp site list --field=url | xargs -n1 -I % wp --url=% theme activate default --allow-root
wp theme delete twentysixteen twentyseventeen twentynineteen twentytwenty twentytwentyone twentytwentytwo --allow-root
wp plugin install WP-PGP-Encrypted-Emails contact-form-7 wpcf7-redirect woocommerce wp-recaptcha-integration duplicate-post wordpress-seo wp-content/themes/default/plugins/advanced-custom-fields-pro.zip wp-content/themes/default/plugins/relevanssi-premium.zip timber-library advanced-custom-fields-table-field onelogin-saml-sso --activate --allow-root
wp plugin update --all --allow-root
wp wc update
wp rewrite flush --allow-root


# remove xmlrpc
rm -f /var/www/html/xmlrpc.php

问题现象

镜像构建完成后启动容器,手动执行wp-install-plugins.sh脚本确认插件安装成功,但访问域名myapp-dev.mydomain.io时页面完全空白,容器及反向代理Nginx均未生成错误日志。

已排查内容

  1. 远程数据库连接已验证正常;
  2. 容器内文件权限情况:
    • /var/www/wp-content下核心文件(如wp-admin、wp-includes)权限为root:root,仅uploads目录为nobody:nobody;
    • /var/www目录下的wp-config.php和wp-install-plugins.sh归属用户组为1001:1002,而WordPress运行用户为nobody。

疑问与求助

  • 当前是否存在权限配置问题导致页面空白?
  • 还有哪些未排查的关键点?
  • 欢迎提供现有配置的优化建议。

内容的提问来源于stack exchange,提问作者merilstack

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 17:43:11