Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WordPress asking for FTP credentials to install plugins #298

Closed
dievardump opened this issue May 6, 2018 · 27 comments
Closed

WordPress asking for FTP credentials to install plugins #298

dievardump opened this issue May 6, 2018 · 27 comments
Labels
question Usability question, not directly related to an error with the image

Comments

@dievardump
Copy link

dievardump commented May 6, 2018

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.

@wglambert wglambert added the question Usability question, not directly related to an error with the image label May 15, 2018
@tianon
Copy link
Member

tianon commented May 15, 2018

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

@dianjuar
Copy link

dianjuar commented Jun 4, 2018

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

@wglambert
Copy link

Issue seems resolved so going to close

@awps
Copy link

awps commented Sep 5, 2018

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.

@sco-tt
Copy link

sco-tt commented Sep 6, 2018

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.

@klederson
Copy link

@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

@tianon
Copy link
Member

tianon commented Oct 8, 2018

As I noted over at #340 (comment), 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).

@cnasikas
Copy link

cnasikas commented Dec 11, 2018

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

@asolopovas
Copy link

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
Copy link

asolopovas commented Jan 5, 2019

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
Copy link

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
Copy link

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

@latetedemelon
Copy link

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/

@MafuraG
Copy link

MafuraG commented Mar 9, 2019

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

@tkodev
Copy link

tkodev commented Apr 13, 2019

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

@hburrows
Copy link

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

@latetedemelon
Copy link

@hburrows - Did you try my solution above?

@hburrows
Copy link

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

@latetedemelon
Copy link

latetedemelon commented Aug 17, 2019 via email

@hburrows
Copy link

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

@latetedemelon
Copy link

latetedemelon commented Aug 17, 2019 via email

@hburrows
Copy link

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

@latetedemelon
Copy link

latetedemelon commented Aug 18, 2019 via email

@hburrows
Copy link

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

@latetedemelon
Copy link

latetedemelon commented Aug 19, 2019 via email

@yosifkit
Copy link
Member

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

@tianon
Copy link
Member

tianon commented Aug 19, 2019

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.

@docker-library docker-library locked as resolved and limited conversation to collaborators Aug 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests