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

Docker部署WordPress插件上传遇阻:Mac下Compose配置后需FTP凭证

Fixing WordPress FTP Credential Prompt in Docker Setup

Hey there! Let's sort out that annoying FTP credential prompt you're getting when trying to upload plugins to your Dockerized WordPress site. I've dealt with this exact issue using similar Docker-Compose configs, so here are a few straightforward solutions to get you up and running:

1. Force WordPress to Use Direct File System Access

The most common fix is telling WordPress to skip FTP and use direct file writes by adding a line to your wp-config.php file. Here's how to do it properly:

Option A: Edit the Container's wp-config.php Temporarily

First, get into your running WordPress container (replace <container-name> with your actual container name—you can find it with docker ps):

docker exec -it <container-name> bash

Once inside, open wp-config.php with a text editor (nano is user-friendly):

nano /var/www/html/wp-config.php

Scroll to the end of the file and add this line:

define('FS_METHOD', 'direct');

Save the file (Ctrl+O, then Enter) and exit nano (Ctrl+X). Now refresh your WordPress admin and try uploading a plugin again—the FTP prompt should be gone.

To make this change stick even if you restart or rebuild your container, copy the wp-config.php file from the container to your local project directory:

docker cp <container-name>:/var/www/html/wp-config.php ./

Edit the local wp-config.php file and add the same FS_METHOD line as above. Then update your docker-compose.yml to mount this local file into the container:
In the wordpress service's volumes section, add:

- ./wp-config.php:/var/www/html/wp-config.php:delegated

Restart your containers to apply the change:

docker-compose down && docker-compose up -d

2. Fix File Permissions

Sometimes the issue comes down to incorrect file ownership in the container. WordPress runs as the www-data user, so make sure it has write access to the wp-content directory:

docker exec -it <container-name> chown -R www-data:www-data /var/www/html/wp-content

This command recursively sets the correct owner for all files and folders in wp-content, allowing WordPress to write directly without needing FTP.

3. Adjust Your Docker Volume Mounts

Right now, your config only mounts your theme directory to the container. Plugins get uploaded to /var/www/html/wp-content/plugins, which is stored inside the container (and will be lost if you rebuild it). To fix this and avoid permission issues long-term, mount the entire wp-content directory to your local project:

  1. Create a wp-content folder in your project root:
mkdir wp-content
  1. Update the wordpress service's volumes in docker-compose.yml to replace your theme mount with:
volumes:
  - ./wp-content:/var/www/html/wp-content:delegated
  1. Restart your containers:
docker-compose down && docker-compose up -d

Now all themes, plugins, and uploads will be stored locally, and you'll avoid permission conflicts that trigger the FTP prompt.


Content of this question comes from Stack Exchange, asked by joshmoto

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 08:43:34