Wordpress: WordPress asking for FTP credentials to install plugins

Created on 6 May 2018  ·  27Comments  ·  Source: docker-library/wordpress

As in #86 WordPress is asking me for FTP credentials to install plugins.

However, uploading medias works fine, as the uploaded medias appear in ./websites/wp-test/wp-content/uploads. So the container seems to have write permission on the wp-content folder.

Any idea what could be the problem ?

configuration :

wordpress:
    image: wordpress:latest
    restart: always
    depends_on:
      - database
    expose:
      - 80
    environment:
      VIRTUAL_HOST: wp-test.docker.local
      VIRTUAL_PORT: 80
      WORDPRESS_DB_HOST: database:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
    volumes:
      - ./websites/wp-test/wp-content:/var/www/html/wp-content 

Current directory permissions are :

drwxrwxrwx 1 root root 48 mai 6 15:59 docker/

But as I said, since medias get uploaded I don't see why the plugins can't be downloaded.
Works fine in a directory owned by my current user.

question

Most helpful comment

If anyone else is facing this issue, this is how I fixed it on ubuntu:

sudo chown -R www-data:www-data path/to/wp-content

_Leaving it here for those who come from search engines._

All 27 comments

Do you have appropriate permissions on the plugins subfolder? By default, it should be something like the following:

drwxr-xr-x 3 www-data www-data 4096 Nov 29 19:06 plugins

(I'm not able to reproduce the issue -- if I setup a new instance with a bind-mounted volume, I'm able to install plugins directly.)

This is an "issue" of WordPress well know.
I create a gist to remember how to "fix it"
https://gist.github.com/dianjuar/1b2c43d38d76e68cf21971fc86eaac8e

Issue seems resolved so going to close

If anyone else is facing this issue, this is how I fixed it on ubuntu:

sudo chown -R www-data:www-data path/to/wp-content

_Leaving it here for those who come from search engines._

Following up on @awps: you can chown your wp-content/.git/ directory (if you have one) to your local user after you chown everything to www-data.

@wglambert it's not solved at all at least not as default... the docker image insists on asking for the credentials...

This should be covered somehow else in the default docker installation once its a basic feature for anyone trying to develop something with wordpress

As I noted over at https://github.com/docker-library/wordpress/pull/340#issuecomment-428010324, if you're getting prompted for FTP credentials, it's because of your filesystem permissions. I think you'll find that if you correct the filesystem permissions, the prompt will go away and installations will complete successfully automatically within the Web UI (since the www-data user that the PHP code runs as needs to be able to write to the directories in order for the web-based installation to succeed).

Despite having the correct permissions for wp-content folder and the user/group www-data, only the above solution (in combinations with correct permissions) worked for me.

This is an "issue" of WordPress well know.
I create a gist to remember how to "fix it"
https://gist.github.com/dianjuar/1b2c43d38d76e68cf21971fc86eaac8e

Guys I have tried eveything you have listed above in linux, nothing seems to work at all.

Here is my docker-compose.yml

version: "3.1"

services:
   db_node_domain:
     image: mariadb
     volumes:
       - ../../../db:/var/lib/mysql
     restart: always
     environment:
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: secret
       MYSQL_ROOT_PASSWORD: password

   phpmyadmin:
     image: phpmyadmin/phpmyadmin
     depends_on:
      - db_node_domain
     restart: always
     environment:
       VIRTUAL_HOST: phpmyadmin.test
       MYSQL_ROOT_PASSWORD: password
       PMA_HOST: db_node_domain
     expose:
       - 80

   redis:
     image: redis

   wordpress:
     depends_on:
      - db_node_domain
      - redis
     image: wordpress:latest
     volumes:
      - ../../:/var/www/html/wp-content/
     expose:
       - 80
     restart: always
     environment:
       VIRTUAL_HOST: wphost.test
       WORDPRESS_DB_HOST: db_node_domain:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: secret
networks:
  default:
    external:
      name: nginx-proxy

I have tried changing permissions inside the container to www-data:www-data for plugins directory, it still asks for ftp, I have tried the bellow

I create a gist to remember how to "fix it"
https://gist.github.com/dianjuar/1b2c43d38d76e68cf21971fc86eaac8e

In this case it says Update Failed: Could not create directory. The permissions inside the container are as follows:

drwxrwxrwx  6 www-data www-data 4096 Jan  5 19:58 advanced-custom-fields-pro
drwxrwxrwx  4 www-data www-data 4096 Jan  5 20:57 akismet
drwxrwxrwx  3 www-data www-data 4096 Aug 31 18:51 automatic-domain-changer
drwxrwxrwx  8 www-data www-data 4096 Mar 13  2018 cloudflare
-rw-rw-rw-  1 www-data www-data 1622 Jan  8  2016 cpaddons-site-software.php
-rw-r--r--  1 www-data www-data 2283 Nov 15 23:38 hello.php
-rw-r--r--  1 www-data www-data   28 Jun  5  2014 index.php
drwxrwxrwx 10 www-data www-data 4096 Jul 25 20:20 redirection
drwxrwxrwx  4 www-data www-data 4096 Aug 31 18:51 tiny-compress-images
drwxrwxrwx  6 www-data www-data 4096 Oct  8  2017 tinymce-advanced
drwxrwxrwx 12 www-data www-data 4096 Aug 31 18:52 wordpress-seo

The plugins folder has exactly same permissions. It just refused to work no matter what I do. So frustrating.

After playing around a bit. It looks like on initial build the wp-content belongs to root:root, so if you change wp-content and wp-content to www-data:www-data you can upload and update your plugins. The problem with such method though is that you have to do it for every project.

Same thing happens with you theme folder so if you have to generate anything inside of it it has to be owned www-data:www-data, and if you do change ownership from inside the container you loose the ability do change mounted volumes on your local machine which kind of uncomfortable if you develop theme on your local machine.

Even if you local permissions have 666 for files and 777 for it refuses to right anything into container folder via web interface. Unless you chown www-data:www-data -R wp-content from inside the container it will not operate as expected.

I think the issue should be reopened as it doesn't have a viable solution. Otherwise, I don't see the reason of having this image, you pretty much have to build your own in order to properly develop themes.

ok the problem seems to be in two places:
1) userid of www-data and 'groupid' is 33 where my local user that owns volumes mounted has uid 1000 and gid 1001, if I change usermod -u 1000 www-data && groupmod -g 1001 www-data inside container then restart it, all folders become owned www-data inside container.
2) Previous fixes the problem partially but new container has the fodler wp-content owned by root:root so if you change that to ẁww-data:www-data things start without problems. And for some reason folder themes owned by root:root as well.

Looks like the only solution is to build your own image and make your containers www-data:www-data uid and gid to reflect the ones used by your local system and change ownership of wp-content and themes folders to www-data:www-data

Just encountered this problem myself; I found mounting the entire content directory seemed to solve the problem: /var/www/html/ instead of /var/www/html/wp-content/

Just encountered this problem myself; I found mounting the entire content directory seemed to solve the problem: /var/www/html/ instead of /var/www/html/wp-content/

This worked for me! Cheers

@asolopovas the solution can be the other way around, do chown -Rf 33:33 ./wp-content on your host.

Since I'm using docker-compose, I like to use a container to do this:

your-app:
    depends_on:
        - site-perms-helper
        ...
site-perms-helper:
    container_name: site-perms-helper
    image: alpine:3.8
    restart: "no"
    networks:
      - default
    volumes:
      - ./sources/wp-content:/srv/wp-content
    command: chown -Rf 33:33 /srv/wp-content && chmod -R a=r,u+w,a+X /srv/wp-content

Kind of extra and runs every restart, but at least I don't have to configure every WordPress folder I make.

@asolopovas Did you ever solve your permissions issues? And if so how? I have the same issue and have tried everything I can possibly think of but nothing works. Neither chown or chmod or running Apache as a different user (root in my case) or changing user/group-ids works. I've tried changing things on both the container and my Mac host. Wordpress simply can't write to wp-content -- I can't upload media, can't install themes or plugins, can't write the debug.out file (if WP_DEBUG enabled). It's a mystery...

@hburrows - Did you try my solution above?

@rmclellan thanks for replying. I did try your solution and it didn't make any difference. It's very baffling. I'm using the setup for plugin development and can function... but it's very frustrating that I can't get it to work properly. I use Docker for all kinds of things so this setup is a natural. Maybe I'd be better off with another virtualization solution for Wordpress development. It must be something simple... what, however, I don't know ???

Post your compose file?

On Fri, Aug 16, 2019, 8:08 PM Howard Burrows, notifications@github.com
wrote:

@rmclellan https://github.com/rmclellan thanks for replying. I did try
your solution and it didn't make any difference. It's very baffling. I'm
using the setup for plugin development and can function... but it's very
frustrating that I can't get it to work properly. I use Docker for all
kinds of things so this setup is a natural. Maybe I'd be better off with
another virtualization solution for Wordpress development. It must be
something simple... what, however, I don't know ???


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/docker-library/wordpress/issues/298?email_source=notifications&email_token=ACDYM2JQIPRWXICDKHUX5ETQE5TRPA5CNFSM4E6QAEW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4QCBQA#issuecomment-522199232,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACDYM2NAX43GYFR35RUE2STQE5TRPANCNFSM4E6QAEWQ
.

@rmclellan Here's my compose file:

version: '3.3'

services:
  db:
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: *****
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress

  wordpress:
    depends_on:
      - db
    image: wordpress
    ports:
      - "8000:80"
    restart: always
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: ******
      WORDPRESS_DB_NAME: wordpress
    working_dir: /var/www/html
    volumes:
      - ./wp-content:/var/www/html/wp-content
      - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
volumes:
    db_data: {}

I'd recommend setting a separate volume directory for the content.

volumes:
vol-wp-db:
vol-wp-content:

wp-db:
image: mariadb:10.3
restart: always
networks:
- backend
volumes:
- vol-wp-db:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: ${WORDPRESS_DB_ROOT_PASSWORD}
MYSQL_DATABASE: ${WORDPRESS_DB_NAME}
MYSQL_USER: ${WORDPRESS_DB_USER}
MYSQL_PASSWORD: ${WORDPRESS_DB_PASSWORD}

wp:
image: wordpress:latest
depends_on:
- wp-db
restart: always
networks:
- backend
- frontend
volumes:
- vol-wp-content:/var/www/html/wp-content
- ./php.ini:/usr/local/etc/php/php.ini
environment:
WORDPRESS_DB_HOST: wp-db:3306
WORDPRESS_DB_NAME: ${WORDPRESS_DB_NAME}
WORDPRESS_DB_USER: ${WORDPRESS_DB_USER}
WORDPRESS_DB_PASSWORD: ${WORDPRESS_DB_PASSWORD}

On Sat, Aug 17, 2019 at 3:52 PM Howard Burrows notifications@github.com
wrote:

@rmclellan https://github.com/rmclellan Here's my compose file:

version: '3.3'

services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: *
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress

wordpress:
depends_on:
- db
image: wordpress
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: **
WORDPRESS_DB_NAME: wordpress
working_dir: /var/www/html
volumes:
- ./wp-content:/var/www/html/wp-content
- ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
volumes:
db_data: {}


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/docker-library/wordpress/issues/298?email_source=notifications&email_token=ACDYM2MIUI6TQ7XPWCF5BRLQFB6LNA5CNFSM4E6QAEW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4QU33Y#issuecomment-522276335,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACDYM2P5ITUDRVONJ6XOHALQFB6LNANCNFSM4E6QAEWQ
.

@rmclellan I want to easily work on the files in the volume from my host machine -- i.e. edit them, manage them with github, etc. I'm using this setup for development so being able to point my editor at these files is really important. It doesn't seem like docker volume (vs a bind mount) works well for this. Maybe I'm misunderstanding how docker volume ... works.

I'm not an expert on the binds but wouldn't you have to change the working
directory to add wp-content as well?

On Sun, Aug 18, 2019 at 8:57 AM Howard Burrows notifications@github.com
wrote:

@rmclellan https://github.com/rmclellan I want to easily work on the
files in the volume from my host machine -- i.e. edit them, manage them
with github, etc. I'm using this setup for development so being able to
point my editor at these files is really important. It doesn't seem like docker
volume (vs a bind mount) works well for this. Maybe I'm misunderstanding
how docker volume ... works.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/docker-library/wordpress/issues/298?email_source=notifications&email_token=ACDYM2JDFS6NLOQ26QCQPFLQFFWP5A5CNFSM4E6QAEW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4RC2XY#issuecomment-522333535,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACDYM2INM3PEGBLCGNIK3VLQFFWP5ANCNFSM4E6QAEWQ
.

@rmclellan I'm not following your question. The setup I'm using works perfectly except for the permissions issue which prevents the Wordpress process from writing to wp-content. When I docker-compose up the wp-content directory is created in the same directory where docker-compose.yml lives and I can locally edit files just fine. Wordpress, however, cannot write to wp-content from the container -- regardless of what I do the container only appears to have readonly permission to the bind-mounted volume. I would love to use docker volume create, but using that to edit files locally seems to be a non-starter. I don't believe docker volume create is intended for that use case.

In your configuration you're binding to a specific existing directory as
opposed to creating a separate volume. However your working directory is a
parent directory of the directory that you're binding. Try changing it to
include the wp-contents.

On Sun, Aug 18, 2019, 12:05 PM Rob M, robert@mclellan.co wrote:

I'm not an expert on the binds but wouldn't you have to change the working
directory to add wp-content as well?

On Sun, Aug 18, 2019 at 8:57 AM Howard Burrows notifications@github.com
wrote:

@rmclellan https://github.com/rmclellan I want to easily work on the
files in the volume from my host machine -- i.e. edit them, manage them
with github, etc. I'm using this setup for development so being able to
point my editor at these files is really important. It doesn't seem like docker
volume (vs a bind mount) works well for this. Maybe I'm misunderstanding
how docker volume ... works.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/docker-library/wordpress/issues/298?email_source=notifications&email_token=ACDYM2JDFS6NLOQ26QCQPFLQFFWP5A5CNFSM4E6QAEW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4RC2XY#issuecomment-522333535,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACDYM2INM3PEGBLCGNIK3VLQFFWP5ANCNFSM4E6QAEWQ
.

So, if you are running on Windows or OSX and using Docker for Windows/Mac, then the linked issues might be related. While they are specifically about databases having issues with volume mapping from VM to host, I think that the fact the Docker for Windows/Mac presents the files as all root owned is a possible culprit (the first link). Unfortunately, if that is the problem, then the only solution would be to run wordpress as root (which apache httpd and php-fpm don't allow).

Additionally, in the future, these sorts of questions/requests/discussions would be more appropriately posted to the Docker Community Forums, the Docker Community Slack, or Stack Overflow.

Was this page helpful?
0 / 5 - 0 ratings