wordpress icon indicating copy to clipboard operation
wordpress copied to clipboard

WordPress asking for FTP credentials to install plugins

Open dievardump opened this issue 8 years ago • 27 comments

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.

dievardump avatar May 06 '18 11:05 dievardump

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.)

tianon avatar May 15 '18 19:05 tianon

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

dianjuar avatar Jun 04 '18 01:06 dianjuar

Issue seems resolved so going to close

wglambert avatar Jun 27 '18 19:06 wglambert

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.

awps avatar Sep 05 '18 13:09 awps

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.

sco-tt avatar Sep 06 '18 22:09 sco-tt

@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

klederson avatar Oct 05 '18 15:10 klederson

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).

tianon avatar Oct 08 '18 23:10 tianon

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

cnasikas avatar Dec 11 '18 18:12 cnasikas

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.

asolopovas avatar Jan 05 '19 21:01 asolopovas

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.

asolopovas avatar Jan 05 '19 22:01 asolopovas

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.

asolopovas avatar Jan 05 '19 22:01 asolopovas

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

asolopovas avatar Jan 05 '19 23:01 asolopovas

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/

latetedemelon avatar Mar 04 '19 07:03 latetedemelon

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

MafuraG avatar Mar 09 '19 21:03 MafuraG

@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.

tkodev avatar Apr 13 '19 05:04 tkodev

@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 avatar Aug 15 '19 21:08 hburrows

@hburrows - Did you try my solution above?

latetedemelon avatar Aug 16 '19 16:08 latetedemelon

@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 ???

hburrows avatar Aug 17 '19 03:08 hburrows

Post your compose file?

On Fri, Aug 16, 2019, 8:08 PM Howard Burrows, [email protected] 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 .

latetedemelon avatar Aug 17 '19 09:08 latetedemelon

@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: {}

hburrows avatar Aug 17 '19 22:08 hburrows