Skip to content

can not upgrade wordpress in the container #369

Closed

Description

@neilpang

Here is my docker-compose file:

web:
  image: wordpress:php7.3
  restart: always
  volumes:
   - ./web:/var/www/html
  environment:
   - WORDPRESS_DB_HOST=db
   - WORDPRESS_DB_USER=exampleuser
   - WORDPRESS_DB_PASSWORD=examplepass
   - WORDPRESS_DB_NAME=exampledb
  links:
   - db:db


db:
  image: mysql:5
  restart: always
  environment:
   - MYSQL_ROOT_PASSWORD=sdfwesd342sdfsdgSfk
   - MYSQL_DATABASE=exampledb
   - MYSQL_USER=exampleuser
   - MYSQL_PASSWORD=examplepass
  volumes:
   - ./db:/var/lib/mysql

I mounted the whole /var/www/html.

The file permissions are correct:

root@ca:~/sites/web# ll
total 212K
drwxr-xr-x  5 root     root     4.0K Jan 29 17:32 .
drwxr-xr-x  5 root     root     4.0K Jan 29 17:26 ..
-rw-r--r--  1 www-data www-data  235 Jan 29 17:28 .htaccess
-rw-r--r--  1 www-data www-data  418 Sep 25  2013 index.php
-rw-r--r--  1 www-data www-data  20K Jan 29 17:33 license.txt
-rw-r--r--  1 www-data www-data 7.3K Jan 29 17:33 readme.html
-rw-r--r--  1 www-data www-data 6.8K Dec 13 09:30 wp-activate.php
drwxr-xr-x  9 www-data www-data 4.0K Jan 10 02:32 wp-admin
-rw-r--r--  1 www-data www-data  364 Dec 19  2015 wp-blog-header.php
-rw-r--r--  1 www-data www-data 1.9K May  3  2018 wp-comments-post.php
-rw-r--r--  1 www-data www-data 2.8K Jan 29 17:33 wp-config-sample.php
-rw-r--r--  1 www-data www-data 3.2K Jan 29 17:32 wp-config.php
drwxr-xr-x  6 www-data www-data 4.0K Jan 29 17:33 wp-content
-rw-r--r--  1 www-data www-data 3.6K Aug 20  2017 wp-cron.php
drwxr-xr-x 19 www-data www-data  12K Jan 10 02:32 wp-includes
-rw-r--r--  1 www-data www-data 2.4K Nov 21  2016 wp-links-opml.php
-rw-r--r--  1 www-data www-data 3.3K Aug 22  2017 wp-load.php
-rw-r--r--  1 www-data www-data  37K Dec 13 08:28 wp-login.php
-rw-r--r--  1 www-data www-data 7.9K Jan 11  2017 wp-mail.php
-rw-r--r--  1 www-data www-data  18K Oct 23 15:04 wp-settings.php
-rw-r--r--  1 www-data www-data  30K Apr 30  2018 wp-signup.php
-rw-r--r--  1 www-data www-data 4.6K Oct 24  2017 wp-trackback.php
-rw-r--r--  1 www-data www-data 3.0K Sep  1  2016 xmlrpc.php

When I click the upgrade or re-install wordpress button in the Updates menu of the dashboard of the workdpress, it requires me to input a Ftp user/password to.

I checked the web root folder and wp-content permissions, they are all correct( xrw for the www-data user)

So I add the following line to wp-config.php

define('FS_METHOD', 'direct');

Then the upgrade button can work now.

what's wrong here? Is there anyone have the same problem ?

Thanks in advance.

Activity

  1. added
    questionUsability question, not directly related to an error with the image
    on Jan 29, 2019
  2. wglambert commented on Jan 29, 2019

    @wglambert

    #298 (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).

    On a default start the /var/www/html is owned by www-data: drwxrwxrwx 5 www-data www-data 4096 Jan 29 17:26 . when you tell Docker to create a volume it does so as root, so for instance you could create the /web/ directory yourself and chown it so it has correct permissions

    $ docker run --rm -dit --name wordpress wordpress
    $ docker exec -it wordpress bash
    
    root@bd973ce2ffa0:/var/www/html# ls -al
    total 208
    drwxrwxrwx  5 www-data www-data  4096 Jan 29 17:26 .
    drwxr-xr-x  4 root     root      4096 Jan 22 21:56 ..
    -rw-r--r--  1 www-data www-data   234 Jan 29 17:26 .htaccess
    -rw-r--r--  1 www-data www-data   418 Sep 25  2013 index.php
    -rw-r--r--  1 www-data www-data 19935 Jan  3 16:24 license.txt
    -rw-r--r--  1 www-data www-data  7415 Mar 18  2018 readme.html
    -rw-r--r--  1 www-data www-data  6878 Dec 13 01:30 wp-activate.php
    drwxr-xr-x  9 www-data www-data  4096 Jan  9 18:32 wp-admin
    -rw-r--r--  1 www-data www-data   364 Dec 19  2015 wp-blog-header.php
    -rw-r--r--  1 www-data www-data  1889 May  2  2018 wp-comments-post.php
    -rw-r--r--  1 www-data www-data  2853 Dec 16  2015 wp-config-sample.php
    drwxr-xr-x  4 www-data www-data  4096 Jan  9 18:32 wp-content
    -rw-r--r--  1 www-data www-data  3669 Aug 20  2017 wp-cron.php
    drwxr-xr-x 19 www-data www-data 12288 Jan  9 18:32 wp-includes
    -rw-r--r--  1 www-data www-data  2422 Nov 21  2016 wp-links-opml.php
    -rw-r--r--  1 www-data www-data  3306 Aug 22  2017 wp-load.php
    -rw-r--r--  1 www-data www-data 37296 Dec 13 00:28 wp-login.php
    -rw-r--r--  1 www-data www-data  8048 Jan 11  2017 wp-mail.php
    -rw-r--r--  1 www-data www-data 17421 Oct 23 07:04 wp-settings.php
    -rw-r--r--  1 www-data www-data 30091 Apr 29  2018 wp-signup.php
    -rw-r--r--  1 www-data www-data  4620 Oct 23  2017 wp-trackback.php
    -rw-r--r--  1 www-data www-data  3065 Aug 31  2016 xmlrpc.php
  3. neilpang commented on Jan 30, 2019

    @neilpang
    ContributorAuthor

    thanks, it works.

    Can this be done in the image? so that it can work out of the box?

    Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionUsability question, not directly related to an error with the image

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions