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

Azure App Service中WordPress无法通过符号链接读取文件

问题:Azure App Service中WordPress容器符号链接导致400错误

我基于官方WordPress Docker镜像在Azure App Service上部署了容器化WordPress项目,仅按照Azure官方文档添加了SSH服务,未对镜像做其他修改。

WordPress容器配置

Dockerfile

FROM wordpress:6.0.3-php7.4

########################################## Add SSH support for Azure ##########################################
# Install OpenSSH and set the password for root to "Docker!".
RUN apt update \
    && apt install -y openssh-server \
    && rm -rf /var/lib/apt/lists/*

RUN echo "root:Docker!" | chpasswd

# Copy the sshd_config file to the /etc/ssh/ directory
COPY docker/ssh/sshd_config /etc/ssh/

# Copy and configure the ssh_setup file
RUN mkdir -p /tmp
COPY docker/ssh/ssh_setup.sh /tmp
RUN chmod +x /tmp/ssh_setup.sh \
    && (sleep 1;/tmp/ssh_setup.sh 2>&1 > /dev/null)

# Open port 2222 for SSH access
EXPOSE 80 2222
###############################################################################################################

COPY docker/script.sh script.sh
RUN chmod +x script.sh
CMD []
ENTRYPOINT ["./script.sh"]

启动脚本docker/script.sh

#!/bin/bash
exec service ssh start &
exec /usr/local/bin/docker-entrypoint.sh apache2-foreground

App Service配置

已添加WEBSITES_ENABLE_APP_SERVICE_STORAGE=true启用持久化存储,并配置WORDPRESS_DB_HOST、WORDPRESS_DB_NAME、WORDPRESS_DB_PASSWORD和WORDPRESS_DB_USER连接外部数据库。

问题重现

  • 完成WordPress初始化后,可正常上传文件,文件存储在/var/www/html/wp-content/uploads/<year>/<month>/<filename>,且能通过https://my-app-service.azurewebsites.net/wp-content/uploads/<year>/<month>/<filename>访问。
  • 为利用Azure仅持久化/home目录的特性,执行以下命令迁移目录并创建符号链接:
$ cd /var/www/html/wp-content
$ mv uploads /home/uploads
$ ln -s /home/uploads uploads
  • 此时访问上述文件URL,仅返回空的400响应。

对比测试

  • 用Python项目做相同测试(迁移目录+符号链接),可正常运行,排除Azure限制。
  • WordPress镜像在本地运行时符号链接功能正常。

请问操作哪里有误?为何Python项目正常而WordPress项目异常?

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 00:41:38